Versions in this module Expand all Collapse all v1 v1.0.1 Sep 20, 2025 v1.0.0 Sep 16, 2025 Changes in this version + type DirMigrationSource struct + AllowedExts []string + Dir string + FilenameParser ParseFilenameFn + ResolveHooks func(filename string) (preHook FileHookFn, postHook FileHookFn) + func NewDirMigrationSource(dir string) *DirMigrationSource + func (d *DirMigrationSource) LoadMigrations() ([]Migration, error) + func (d *DirMigrationSource) WithAllowedExts(exts []string) *DirMigrationSource + func (d *DirMigrationSource) WithFilenameParser(parser ParseFilenameFn) *DirMigrationSource + type Executor interface + ExecContext func(ctx context.Context, query string, args ...any) (sql.Result, error) + type FileHookFn func(ctx context.Context, exec Executor, filePath string) error + type FileMigrationSource struct + FilePath string + FilenameParser ParseFilenameFn + PostHook FileHookFn + PreHook FileHookFn + func NewFileMigrationSource(filePath string) *FileMigrationSource + func (f *FileMigrationSource) LoadMigrations() ([]Migration, error) + func (f *FileMigrationSource) WithFilenameParser(parser ParseFilenameFn) *FileMigrationSource + func (f *FileMigrationSource) WithPostHook(postHook FileHookFn) *FileMigrationSource + func (f *FileMigrationSource) WithPreHook(preHook FileHookFn) *FileMigrationSource + type HistoryManager interface + AppliedMigrations func(ctx context.Context, db *sql.DB, tableName string, migrationName string) (map[string]bool, error) + EnsureHistoryTable func(ctx context.Context, db *sql.DB, tableName string) error + RecordMigration func(ctx context.Context, exec Executor, tableName string, mig Migration, ...) error + RemoveMigration func(ctx context.Context, exec Executor, tableName string, mig Migration, ...) error + type HookFn func(ctx context.Context, exec Executor) error + type HookMigrationStep struct + DownHook HookFn + UpHook HookFn + func NewHookMigrationStep() *HookMigrationStep + func (h *HookMigrationStep) WithDownHook(downHook HookFn) MigrationStep + func (h *HookMigrationStep) WithUpHook(upHook HookFn) MigrationStep + func (h HookMigrationStep) ExecuteDown(ctx context.Context, exec Executor) error + func (h HookMigrationStep) ExecuteUp(ctx context.Context, exec Executor) error + type Migration struct + DownSteps []MigrationStep + Name string + UpSteps []MigrationStep + Version string + func NewMigration(version string, name string) *Migration + func (m *Migration) WithDownSteps(downSteps []MigrationStep) *Migration + func (m *Migration) WithName(name string) *Migration + func (m *Migration) WithUpSteps(upSteps []MigrationStep) *Migration + func (m *Migration) WithVersion(version string) *Migration + type MigrationSource interface + LoadMigrations func() ([]Migration, error) + type MigrationStep interface + ExecuteDown func(ctx context.Context, exec Executor) error + ExecuteUp func(ctx context.Context, exec Executor) error + type Migrator struct + DB *sql.DB + HistoryManager HistoryManager + HistoryTable string + MigrationName string + Sources []MigrationSource + Transactional bool + func NewMigrator(db *sql.DB, historyTable string, historyManager HistoryManager, ...) *Migrator + func (m *Migrator) LoadAllMigrations() ([]Migration, error) + func (m *Migrator) MigrateDown(ctx context.Context, target string) error + func (m *Migrator) MigrateUp(ctx context.Context, target string) error + func (m *Migrator) WithDB(db *sql.DB) *Migrator + func (m *Migrator) WithHistoryManager(historyManager HistoryManager) *Migrator + func (m *Migrator) WithHistoryTable(historyTable string) *Migrator + func (m *Migrator) WithMigrationName(migrationName string) *Migrator + func (m *Migrator) WithSources(sources []MigrationSource) *Migrator + func (m *Migrator) WithTransactional(transactional bool) *Migrator + type MySQLHistoryManager struct + func NewMySQLHistoryManager() *MySQLHistoryManager + func (m MySQLHistoryManager) AppliedMigrations(ctx context.Context, db *sql.DB, tableName string, migrationName string) (map[string]bool, error) + func (m MySQLHistoryManager) EnsureHistoryTable(ctx context.Context, db *sql.DB, tableName string) error + func (m MySQLHistoryManager) RecordMigration(ctx context.Context, exec Executor, tableName string, mig Migration, ...) error + func (m MySQLHistoryManager) RemoveMigration(ctx context.Context, exec Executor, tableName string, mig Migration, ...) error + type ParseFilenameFn func(filename string) (version string, name string, direction string, ok bool) + type SQLMigrationStep struct + SQL string + func NewSQLMigrationStep(sql string) *SQLMigrationStep + func (s *SQLMigrationStep) WithSQL(sql string) *SQLMigrationStep + func (s SQLMigrationStep) ExecuteDown(ctx context.Context, exec Executor) error + func (s SQLMigrationStep) ExecuteUp(ctx context.Context, exec Executor) error + type SQLiteHistoryManager struct + func NewSQLiteHistoryManager() *SQLiteHistoryManager + func (s SQLiteHistoryManager) AppliedMigrations(ctx context.Context, db *sql.DB, tableName string, migrationName string) (map[string]bool, error) + func (s SQLiteHistoryManager) EnsureHistoryTable(ctx context.Context, db *sql.DB, tableName string) error + func (s SQLiteHistoryManager) RecordMigration(ctx context.Context, exec Executor, tableName string, mig Migration, ...) error + func (s SQLiteHistoryManager) RemoveMigration(ctx context.Context, exec Executor, tableName string, mig Migration, ...) error + type VarMigrationSource struct + DownSQL string + Name string + UpSQL string + Version string + func NewVarMigrationSource(version string, name string, upSQL string, downSQL string) *VarMigrationSource + func (v *VarMigrationSource) LoadMigrations() ([]Migration, error)