Versions in this module Expand all Collapse all v1 v1.2.0 Aug 28, 2026 Changes in this version + const DefaultMigrationConfigPath + const PostgresTestConnectionString + func ApplyMigrations(ctx context.Context, migrator Migrator, set *MigrationSet, lastVersion string, ...) error + func GenerateSQLiteMigration(tb testing.TB, target string, migrations string) []string + func MigrationChecksum(content []byte) string + func MigrationSlug(text string) string + func MigrationVerifyDirectory(set *MigrationSet) (string, func(), error) + func MigrationVersionOfTime(moment time.Time) string + func RenderMigrationFile(toolVersion string, generatedAt time.Time, instructions []drivers.Instruction) string + func RenderMigrationPreview(set *MigrationSet) (string, error) + func RenderMigrationStatus(set *MigrationSet) string + func RunMigrationPreview(ctx context.Context, migrator Migrator, set *MigrationSet, output io.Writer) error + func RunMigrationRepair(ctx context.Context, migrator Migrator, set *MigrationSet, output io.Writer) error + func StepMigration(ctx context.Context, migrator Migrator, set *MigrationSet, input io.Reader, ...) error + func WriteMigrationFiles(directory string, slug string, generatedAt time.Time, toolVersion string, ...) ([]string, error) + func WriteSQLFile(tb testing.TB, directory string, name string, content string) string + type AppliedMigration struct + AppliedAt time.Time + Checksum string + Dirty bool + Name string + Version string + type Migration struct + Checksum string + Name string + Path string + Version string + func ParseMigrationFileName(fileName string) (*Migration, error) + func ReadMigrationDirectory(directory string) ([]*Migration, error) + type MigrationConfig struct + Driver drivers.DriverName + Schema string + Source string + Target string + Version string + func ReadMigrationConfig(path string, optional bool) (*MigrationConfig, error) + type MigrationEntry struct + AppliedAt time.Time + Migration *Migration + State MigrationState + func (e *MigrationEntry) Content() (string, error) + func (e *MigrationEntry) FileName() string + type MigrationSet struct + Entries []*MigrationEntry + func LoadMigrationSet(ctx context.Context, migrator Migrator, directory string) (*MigrationSet, error) + func NewMigrationSet(files []*Migration, applied []AppliedMigration) *MigrationSet + func (s *MigrationSet) Pending() []*MigrationEntry + func (s *MigrationSet) ProblemError() error + func (s *MigrationSet) Problems() []*MigrationEntry + func (s *MigrationSet) RecordError() error + type MigrationState string + const MigrationApplied + const MigrationChanged + const MigrationDirty + const MigrationMissing + const MigrationOutOfOrder + const MigrationPending + type MigrationTransaction interface + Apply func(ctx context.Context, statement string) error + Commit func() error + Record func(ctx context.Context, migration *Migration) error + Rollback func() error + type Migrator interface + AppliedMigrations func(ctx context.Context) ([]AppliedMigration, error) + Begin func(ctx context.Context, useTransaction bool) (MigrationTransaction, error) + ClearDirty func(ctx context.Context, migration *Migration) error + Close func() error + DeleteRecord func(ctx context.Context, version string) error + EnsureHistoryTable func(ctx context.Context) error + Lock func(ctx context.Context) error + RecordDirty func(ctx context.Context, migration *Migration) error + TryLock func(ctx context.Context) (bool, error) + Unlock func(ctx context.Context) error + UpdateChecksum func(ctx context.Context, migration *Migration) error + func NewMigrator(ctx context.Context, driverName drivers.DriverName, target string, ...) (Migrator, error) + type PostgresMigrationTransaction struct + Executor migrationExecutor + Transaction *sql.Tx + func (t *PostgresMigrationTransaction) Apply(ctx context.Context, statement string) error + func (t *PostgresMigrationTransaction) Commit() error + func (t *PostgresMigrationTransaction) Record(ctx context.Context, migration *Migration) error + func (t *PostgresMigrationTransaction) Rollback() error + type PostgresMigrator struct + Connection *sql.Conn + Database *sql.DB + func NewPostgresMigrator(ctx context.Context, connectionString string, schema string) (*PostgresMigrator, error) + func (m *PostgresMigrator) AppliedMigrations(ctx context.Context) ([]AppliedMigration, error) + func (m *PostgresMigrator) Begin(ctx context.Context, useTransaction bool) (MigrationTransaction, error) + func (m *PostgresMigrator) ClearDirty(ctx context.Context, migration *Migration) error + func (m *PostgresMigrator) Close() error + func (m *PostgresMigrator) DeleteRecord(ctx context.Context, version string) error + func (m *PostgresMigrator) EnsureHistoryTable(ctx context.Context) error + func (m *PostgresMigrator) Lock(ctx context.Context) error + func (m *PostgresMigrator) RecordDirty(ctx context.Context, migration *Migration) error + func (m *PostgresMigrator) TryLock(ctx context.Context) (bool, error) + func (m *PostgresMigrator) Unlock(ctx context.Context) error + func (m *PostgresMigrator) UpdateChecksum(ctx context.Context, migration *Migration) error + type SQLiteMigrationTransaction struct + Executor migrationExecutor + Transaction *sql.Tx + func (t *SQLiteMigrationTransaction) Apply(ctx context.Context, statement string) error + func (t *SQLiteMigrationTransaction) Commit() error + func (t *SQLiteMigrationTransaction) Record(ctx context.Context, migration *Migration) error + func (t *SQLiteMigrationTransaction) Rollback() error + type SQLiteMigrator struct + Connection *sql.DB + func NewSQLiteMigrator(path string) (*SQLiteMigrator, error) + func (m *SQLiteMigrator) AppliedMigrations(ctx context.Context) ([]AppliedMigration, error) + func (m *SQLiteMigrator) Begin(ctx context.Context, useTransaction bool) (MigrationTransaction, error) + func (m *SQLiteMigrator) ClearDirty(ctx context.Context, migration *Migration) error + func (m *SQLiteMigrator) Close() error + func (m *SQLiteMigrator) DeleteRecord(ctx context.Context, version string) error + func (m *SQLiteMigrator) EnsureHistoryTable(ctx context.Context) error + func (m *SQLiteMigrator) Lock(ctx context.Context) error + func (m *SQLiteMigrator) RecordDirty(ctx context.Context, migration *Migration) error + func (m *SQLiteMigrator) TryLock(ctx context.Context) (bool, error) + func (m *SQLiteMigrator) Unlock(ctx context.Context) error + func (m *SQLiteMigrator) UpdateChecksum(ctx context.Context, migration *Migration) error + type TestingPostgresMigrator struct + func NewTestPostgresMigrator(tb testing.TB) *TestingPostgresMigrator + func (m *TestingPostgresMigrator) Schema() string + func (m *TestingPostgresMigrator) TableNames() []string + type TestingSQLiteMigrator struct + Path string + func NewTestSQLiteMigrator(tb testing.TB) *TestingSQLiteMigrator + func (m *TestingSQLiteMigrator) TableNames() []string