Documentation ¶
Index ¶
- Variables
- func FindMigrations(fsys fs.FS) ([]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 ErrorLineExtract
- 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(fsys fs.FS) error
- func (m *Migrator) Migrate(ctx context.Context) error
- func (m *Migrator) MigrateTo(ctx context.Context, targetVersion int32) (err error)
- 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 ¶
FindMigrations finds all migration files in fsys.
func InstallCodePackage ¶
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 ¶
type CodePackage struct {
// contains filtered or unexported fields
}
func LoadCodePackage ¶
func LoadCodePackage(fsys fs.FS) (*CodePackage, error)
type ErrorLineExtract ¶
type ErrorLineExtract struct { LineNum int // Line number starting with 1 ColumnNum int // Column number starting with 1 Text string // Text of the line without a new line character. }
func ExtractErrorLine ¶
func ExtractErrorLine(source string, position int) (ErrorLineExtract, error)
ExtractErrorLine takes source and character position extracts the line number, column number, and the line of text.
The first character is position 1.
type IrreversibleMigrationError ¶
type IrreversibleMigrationError struct {
// contains filtered or unexported fields
}
func (IrreversibleMigrationError) Error ¶
func (e IrreversibleMigrationError) Error() string
type MigrationPgError ¶
func (MigrationPgError) Error ¶
func (e MigrationPgError) Error() string
func (MigrationPgError) Unwrap ¶
func (e MigrationPgError) Unwrap() error
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 ¶
func NewMigratorEx(ctx context.Context, conn *pgx.Conn, 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 ¶
type MigratorOptions ¶
type MigratorOptions struct { // DisableTx causes the Migrator not to run migrations in a transaction. DisableTx bool }
type NoMigrationsFoundError ¶
type NoMigrationsFoundError struct{}
func (NoMigrationsFoundError) Error ¶
func (e NoMigrationsFoundError) Error() string
Click to show internal directories.
Click to hide internal directories.