Documentation
¶
Index ¶
- Variables
- func FindMigrations(path string) ([]string, error)
- func FindMigrationsEx(path string, fs MigratorFS) ([]string, error)
- func InstallCodePackage(ctx context.Context, conn *pgx.Conn, mergeData map[string]interface{}, ...) (err error)
- func LockExecTx(ctx context.Context, conn *pgx.Conn, sql string) (err error)
- type BadVersionError
- type CodePackage
- type Connector
- type IrreversibleMigrationError
- type Migration
- type MigrationPgError
- type Migrator
- func (m *Migrator) AppendMigration(name, upSQL, downSQL string)
- func (m *Migrator) GetCurrentVersion(ctx context.Context) (v int32, err error)
- func (m *Migrator) LoadMigrations(path string) error
- func (m *Migrator) Migrate(ctx context.Context) error
- func (m *Migrator) MigrateTo(ctx context.Context, targetVersion int32) (err error)
- type MigratorFS
- type MigratorOptions
- type NoMigrationsFoundError
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoFwMigration = errors.New("no sql in forward migration step")
Functions ¶
func FindMigrations ¶ added in v1.2.0
func FindMigrationsEx ¶ added in v1.8.0
func FindMigrationsEx(path string, fs MigratorFS) ([]string, error)
func InstallCodePackage ¶ added in v1.12.5
func InstallCodePackage(ctx context.Context, conn *pgx.Conn, mergeData map[string]interface{}, codePackage *CodePackage) (err error)
Types ¶
type BadVersionError ¶
type BadVersionError string
func (BadVersionError) Error ¶
func (e BadVersionError) Error() string
type CodePackage ¶ added in v1.12.5
type CodePackage struct {
// contains filtered or unexported fields
}
func LoadCodePackage ¶ added in v1.12.5
func LoadCodePackage(path string) (*CodePackage, error)
func LoadCodePackageEx ¶ added in v1.12.5
func LoadCodePackageEx(path string, fs MigratorFS) (*CodePackage, error)
type Connector ¶ added in v1.12.5
type Connector interface { Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row Begin(ctx context.Context) (pgx.Tx, error) }
type IrreversibleMigrationError ¶
type IrreversibleMigrationError struct {
// contains filtered or unexported fields
}
func (IrreversibleMigrationError) Error ¶
func (e IrreversibleMigrationError) Error() string
type MigrationPgError ¶ added in v1.12.5
type Migrator ¶
type Migrator struct { Migrations []*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 ¶
NewMigrator initializes a new Migrator. It is highly recommended that versionTable be schema qualified.
func NewMigratorEx ¶ added in v1.8.0
func NewMigratorEx(ctx context.Context, conn Connector, 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) GetCurrentVersion ¶
func (*Migrator) LoadMigrations ¶
type MigratorFS ¶ added in v1.8.0
type MigratorOptions ¶ added in v1.8.0
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.