migrate

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2021 License: BSD-2-Clause Imports: 15 Imported by: 348

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migration

type Migration struct {
	bun.BaseModel

	ID         int64
	Name       string
	GroupID    int64
	MigratedAt time.Time `bun:",notnull,nullzero,default:current_timestamp"`

	Up   MigrationFunc `bun:"-"`
	Down MigrationFunc `bun:"-"`
}

func (*Migration) String added in v0.3.0

func (m *Migration) String() string

type MigrationFile added in v0.3.0

type MigrationFile struct {
	FileName string
	FilePath string
	Content  string
}

type MigrationFunc

type MigrationFunc func(ctx context.Context, db *bun.DB) error

func NewSQLMigrationFunc

func NewSQLMigrationFunc(fsys fs.FS, name string) MigrationFunc

type MigrationGroup added in v0.3.0

type MigrationGroup struct {
	ID         int64
	Migrations MigrationSlice
}

func (*MigrationGroup) String added in v0.3.0

func (g *MigrationGroup) String() string

type MigrationSlice added in v0.3.0

type MigrationSlice []Migration

func (MigrationSlice) String added in v0.3.0

func (ms MigrationSlice) String() string

type MigrationStatus added in v0.3.0

type MigrationStatus struct {
	Migrations    MigrationSlice
	NewMigrations MigrationSlice
	LastGroup     *MigrationGroup
}

type Migrations

type Migrations struct {
	// contains filtered or unexported fields
}

func NewMigrations

func NewMigrations(opts ...MigrationsOption) *Migrations

func (*Migrations) Discover

func (m *Migrations) Discover(fsys fs.FS) error

func (*Migrations) DiscoverCaller

func (m *Migrations) DiscoverCaller() error

func (*Migrations) Migrations

func (m *Migrations) Migrations() MigrationSlice

func (*Migrations) MustRegister

func (m *Migrations) MustRegister(up, down MigrationFunc)

func (*Migrations) Register

func (m *Migrations) Register(up, down MigrationFunc) error

type MigrationsOption

type MigrationsOption func(m *Migrations)

func WithMigrationsDirectory added in v0.3.0

func WithMigrationsDirectory(directory string) MigrationsOption

type Migrator added in v0.3.0

type Migrator struct {
	// contains filtered or unexported fields
}

func NewMigrator added in v0.3.0

func NewMigrator(db *bun.DB, migrations *Migrations, opts ...MigratorOption) *Migrator

func (*Migrator) CreateGo added in v0.3.0

func (m *Migrator) CreateGo(ctx context.Context, name string) (*MigrationFile, error)

func (*Migrator) CreateSQL added in v0.3.0

func (m *Migrator) CreateSQL(ctx context.Context, name string) (*MigrationFile, error)

func (*Migrator) Init added in v0.3.0

func (m *Migrator) Init(ctx context.Context) error

func (*Migrator) Lock added in v0.3.0

func (m *Migrator) Lock(ctx context.Context) error

func (*Migrator) MarkCompleted added in v0.3.0

func (m *Migrator) MarkCompleted(ctx context.Context) (*MigrationGroup, error)

func (*Migrator) Migrate added in v0.3.0

func (m *Migrator) Migrate(ctx context.Context) (*MigrationGroup, error)

func (*Migrator) Rollback added in v0.3.0

func (m *Migrator) Rollback(ctx context.Context) (*MigrationGroup, error)

func (*Migrator) Status added in v0.3.0

func (m *Migrator) Status(ctx context.Context) (*MigrationStatus, error)

func (*Migrator) Unlock added in v0.3.0

func (m *Migrator) Unlock(ctx context.Context) error

type MigratorOption added in v0.3.0

type MigratorOption func(m *Migrator)

func WithLocksTableName

func WithLocksTableName(table string) MigratorOption

func WithTableName

func WithTableName(table string) MigratorOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL