Versions in this module Expand all Collapse all v0 v0.2.0 Feb 5, 2024 Changes in this version + const Version + var ErrIntegrityProtection = errors.New("adapt: abort due to integrity protection rules. See log output for details") + var ErrInvalidSource = errors.New("adapt: source violated a precondition. See log output for details") + func Migrate(executor string, driver Driver, sources SourceCollection, options ...Option) error + type AvailableMigration struct + Hash *string + ID string + ParsedUp *ParsedMigration + Source Source + func (m *AvailableMigration) Enrich(log *slog.Logger) error + type DBTarget interface + Exec func(query string, args ...interface{}) (sql.Result, error) + Query func(query string, args ...interface{}) (*sql.Rows, error) + type DatabaseDriver interface + DB func() *sql.DB + DeleteMigration func(migrationID string, target DBTarget) error + SupportsTx func() bool + TxBeginOpts func() (ctx context.Context, opts *sql.TxOptions) + func FromSqlStatementsDriver(driver SqlStatementsDriver) DatabaseDriver + func NewMySQLDriver(db *sql.DB, opts ...MySQLOption) DatabaseDriver + func NewPostgresDriver(db *sql.DB, opts ...PostgresOption) DatabaseDriver + func NewSQLiteDriver(db *sql.DB, opts ...SQLiteOption) DatabaseDriver + type DatabaseDriverCustomMigration interface + Migrate func(migration *ParsedMigration, beforeFinish func(target DBTarget) error) error + type DirEntry interface + IsDir func() bool + Name func() string + type Driver interface + AcquireLock func() error + AddMigration func(migration *Migration) error + Close func() error + Healthy func() error + Init func(log *slog.Logger) error + ListMigrations func() ([]*Migration, error) + Name func() string + ReleaseLock func() error + SetMigrationToFinished func(migrationID string) error + SupportsLocks func() bool + func NewFileDriver(filename string, opts ...FileDriverOption) Driver + type FileDriverOption func(*fileDriver) error + func FileDriverFilePermission(perm os.FileMode) FileDriverOption + type FilesystemAdapter interface + Open func(name string) (io.ReadCloser, error) + ReadDir func(name string) ([]DirEntry, error) + type Hook struct + MigrateDown func() *ParsedMigration + MigrateUp func() error + MigrateUpDB func(db *sql.DB) error + MigrateUpTx func(tx *sql.Tx) error + type HookSource interface + GetHook func(id string) Hook + func NewCodePackageSource(pkg map[string]Hook) HookSource + func NewCodeSource(id string, hook Hook) HookSource + type Migration struct + Adapt string + Deployment string + DeploymentOrder int + Down *[]byte + Executor string + Finished *time.Time + Hash *string + ID string + Started time.Time + type MySQLOption func(*mysqlDriver) error + func MySQLDBCreateStatement(stmt string) MySQLOption + func MySQLDBName(dbName string) MySQLOption + func MySQLDisableDBClose() MySQLOption + func MySQLDisableTx() MySQLOption + func MySQLTableName(tableName string) MySQLOption + func MySQLTxBeginOpts(factory func() (context.Context, *sql.TxOptions)) MySQLOption + type Option func(*exec) error + func CustomLogger(log *slog.Logger) Option + func DisableDriverLocks() Option + func DisableHashIntegrityChecks() Option + func DisableLogger() Option + type ParsedMigration struct + Stmts []string + UseTx bool + func Parse(r io.Reader) (*ParsedMigration, error) + func (m *ParsedMigration) Hash() *string + type PostgresOption func(*postgresDriver) error + type SQLiteOption func(*sqliteDriver) error + func SQLiteDisableTx() SQLiteOption + func SQLiteTxBeginOpts(factory func() (context.Context, *sql.TxOptions)) SQLiteOption + type Source interface + Init func(log *slog.Logger) error + ListMigrations func() ([]string, error) + type SourceCollection []Source + type SqlStatementsDriver interface + AcquireLock func() (query string) + AddMigration func(m *Migration) (query string, args []interface{}) + Close func() error + DB func() *sql.DB + DeleteMigration func(migrationID string) (query string, args []interface{}) + Healthy func() error + Init func(log *slog.Logger) error + ListMigrations func() (query string) + Name func() string + ReleaseLock func() (query string) + SetMigrationToFinished func(migrationID string) (query string, args []interface{}) + SupportsLocks func() bool + SupportsTx func() bool + TxBeginOpts func() (ctx context.Context, opts *sql.TxOptions) + UseGlobalTx func() bool + type SqlStatementsSource interface + GetParsedDownMigration func(id string) (*ParsedMigration, error) + GetParsedUpMigration func(id string) (*ParsedMigration, error) + func FromFilesystemAdapter(adapter FilesystemAdapter, directory string) SqlStatementsSource + func NewEmbedFSSource(fs embed.FS, directory string) SqlStatementsSource + func NewFilesystemSource(directory string) SqlStatementsSource + func NewMemoryFSSource(fs map[string]string) SqlStatementsSource