Documentation ¶
Index ¶
- Variables
- func FindMigrations(path string) ([]string, error)
- func FindMigrationsEx(path string, fs MigratorFS) ([]string, error)
- func Position(a []string, x string) int
- func Reverse(s []string)
- type BadVersionError
- type DBConnection
- type IrreversibleMigrationError
- type MigraionDirection
- type Migration
- type MigrationNotFound
- type MigrationPgError
- type Migrator
- func (m *Migrator) AppendMigration(name, upSQL, downSQL string)
- func (m *Migrator) EnableFake()
- func (m *Migrator) GetCurrentVersion(ctx context.Context) (v []string, err error)
- func (m *Migrator) GetDirection(ctx context.Context, targetMigration string) (MigraionDirection, error)
- func (m *Migrator) LoadMigrations(path string) error
- func (m *Migrator) Migrate(ctx context.Context) error
- func (m *Migrator) MigrateTo(ctx context.Context, targetMigration string) (err error)
- func (m *Migrator) MigrationsToApply(ctx context.Context) ([]string, error)
- type MigratorFS
- type MigratorOptions
- type NoMigrationsFoundError
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoFwMigration = errors.Errorf("no sql in forward migration step")
View Source
var ErrNoMigrations = errors.Errorf("no rows in result set")
Functions ¶
func FindMigrations ¶
func FindMigrationsEx ¶
func FindMigrationsEx(path string, fs MigratorFS) ([]string, error)
Types ¶
type BadVersionError ¶
type BadVersionError string
func (BadVersionError) Error ¶
func (e BadVersionError) Error() string
type DBConnection ¶
type DBConnection interface { Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) Begin(ctx context.Context) (pgx.Tx, error) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row }
type IrreversibleMigrationError ¶
type IrreversibleMigrationError struct {
// contains filtered or unexported fields
}
func (IrreversibleMigrationError) Error ¶
func (e IrreversibleMigrationError) Error() string
type MigraionDirection ¶
type MigraionDirection int
const ( Back MigraionDirection = iota Forward NotFound )
type MigrationNotFound ¶
type MigrationNotFound struct {
MigrationName string
}
func (MigrationNotFound) Error ¶
func (e MigrationNotFound) Error() string
type MigrationPgError ¶
type Migrator ¶
type Migrator struct { Migrations map[string]*Migration OnStart func(int32, string, string, string) // OnStart is called when a migration is run with the sequence, name, direction, and SQL Data map[string]interface{} // Data available to use in migrations // contains filtered or unexported fields }
func NewMigrator ¶
func NewMigrator(ctx context.Context, conn DBConnection, versionTable string) (m *Migrator, err error)
NewMigrator initializes a new Migrator. It is highly recommended that versionTable be schema qualified.
func NewMigratorEx ¶
func NewMigratorEx(ctx context.Context, conn DBConnection, versionTable string, opts *MigratorOptions) (m *Migrator, err error)
NewMigratorEx initializes a new Migrator. It is highly recommended that versionTable be schema qualified.
func (*Migrator) AppendMigration ¶
func (*Migrator) EnableFake ¶
func (m *Migrator) EnableFake()
func (*Migrator) GetCurrentVersion ¶
func (*Migrator) GetDirection ¶
func (*Migrator) LoadMigrations ¶
func (*Migrator) Migrate ¶
Migrate runs pending migrations It calls m.OnStart when it begins a migration
type MigratorFS ¶
type MigratorOptions ¶
type MigratorOptions struct { // DisableTx causes the Migrator not to run migrations in a transaction. DisableTx bool // MigratorFS is the interface used for collecting the migrations. MigratorFS MigratorFS }
type NoMigrationsFoundError ¶
type NoMigrationsFoundError struct {
Path string
}
func (NoMigrationsFoundError) Error ¶
func (e NoMigrationsFoundError) Error() string
Click to show internal directories.
Click to hide internal directories.