Versions in this module Expand all Collapse all v0 v0.0.1 Mar 28, 2025 v0.0.0 Mar 28, 2025 Changes in this version + var BadVersion = badVersion + func NewSQLDB(db *sql.DB, q *Queries) *sqlDB + type Database interface + DefaultStepFunc func(ctx context.Context, info StepInfo, dryRun bool, log Logger) error + InitVersion func(ctx context.Context, v Version, dryRun bool) error + Version func(context.Context) (Version, error) + type Error string + const ErrAbort + const ErrAlreadyInitialized + const ErrBadParameters + const ErrBadVersion + const ErrBadVersionChecksum + const ErrBadVersionID + const ErrBeginTx + const ErrCancel + const ErrCommitTx + const ErrEndOfSteps + const ErrNotInitialized + const ErrNotSQLDB + const ErrRollbackTx + func (e Error) Error() string + type Field struct + Key string + Value any + func F(key string, value any) Field + type LogAdapter struct + func (a *LogAdapter) Debug(msg string, fields ...Field) + func (a *LogAdapter) Error(msg string, fields ...Field) + func (a *LogAdapter) Info(msg string, fields ...Field) + func (a *LogAdapter) Level() LogLevel + func (a *LogAdapter) SetLevel(lvl LogLevel) + func (a *LogAdapter) Warn(msg string, fields ...Field) + type LogLevel int + const LevelDebug + const LevelError + const LevelInfo + const LevelNoLog + const LevelWarn + type Logger interface + Debug func(msg string, fields ...Field) + Error func(msg string, fields ...Field) + Info func(msg string, fields ...Field) + Level func() LogLevel + SetLevel func(level LogLevel) + Warn func(msg string, fields ...Field) + func NewLogLogger(lvl LogLevel) Logger + func NewLogLoggerWith(logger *log.Logger, lvl LogLevel) Logger + func NewNilLogger() Logger + func NewSlogLogger(lvl LogLevel) Logger + func NewSlogLoggerWith(logger *slog.Logger, lvl LogLevel) Logger + type Migrater interface + AllDown func(ctx context.Context) error + AllUp func(ctx context.Context) error + Init func() error + InitDryRun func() error + OneDown func(ctx context.Context) error + OneDownDryRun func(ctx context.Context) error + OneUp func(ctx context.Context) error + OneUpDryRun func(ctx context.Context) error + Version func() (Version, error) + type Migrator struct + func New(db Database, steps Stepper, l Logger) (*Migrator, error) + func (m *Migrator) AllDown() error + func (m *Migrator) AllDownCtx(ctx context.Context) error + func (m *Migrator) AllUp() error + func (m *Migrator) AllUpCtx(ctx context.Context) error + func (m *Migrator) Init() error + func (m *Migrator) InitCtx(ctx context.Context) error + func (m *Migrator) InitDryRun() error + func (m *Migrator) InitDryRunCtx(ctx context.Context) error + func (m *Migrator) OneDown() error + func (m *Migrator) OneDownCtx(ctx context.Context) error + func (m *Migrator) OneDownDryRun() error + func (m *Migrator) OneDownDryRunCtx(ctx context.Context) error + func (m *Migrator) OneUp() error + func (m *Migrator) OneUpCtx(ctx context.Context) error + func (m *Migrator) OneUpDryRun() error + func (m *Migrator) OneUpDryRunCtx(ctx context.Context) error + func (m *Migrator) Version() (v Version, err error) + func (m *Migrator) VersionCtx(ctx context.Context) (Version, error) + type NilAdapter struct + func (a *NilAdapter) Debug(msg string, fields ...Field) + func (a *NilAdapter) Error(msg string, fields ...Field) + func (a *NilAdapter) Info(msg string, fields ...Field) + func (a *NilAdapter) Level() LogLevel + func (a *NilAdapter) SetLevel(lvl LogLevel) + func (a *NilAdapter) Warn(msg string, fields ...Field) + type NoTxFunc func(ctx context.Context, db SQLDB, info StepInfo, log Logger) error + type Queries struct + CreateTableQuery string + InitTableQuery string + SetVersionQuery string + VersionQuery string + func (q *Queries) Replace(defaultTableName, newTableName string) + type SQLCommand struct + Args []any + Cmd string + func Cmd(cmd string, args ...any) SQLCommand + func (c SQLCommand) String() string + type SQLDB interface + DB func() *sql.DB + Queries func() *Queries + SetVersion func(ctx context.Context, info StepInfo, dryRun bool, log Logger) error + SetVersionTx func(tx SQLTx, info StepInfo, dryRun bool, log Logger) error + StartTransaction func(ctx context.Context, opts *sql.TxOptions) (SQLTx, error) + VersionTx func(tx SQLTx) (Version, error) + type SQLTx interface + FinalizeTransaction func(err *error, dryRun bool) + Tx func() *sql.Tx + type SlogAdapter struct + func (a *SlogAdapter) Debug(msg string, fields ...Field) + func (a *SlogAdapter) Error(msg string, fields ...Field) + func (a *SlogAdapter) Info(msg string, fields ...Field) + func (a *SlogAdapter) Level() LogLevel + func (a *SlogAdapter) SetLevel(lvl LogLevel) + func (a *SlogAdapter) Warn(msg string, fields ...Field) + type StepFunc func(ctx context.Context, db Database, info StepInfo, dryRun bool, log Logger) error + func NoTx(cmds ...SQLCommand) StepFunc + func NoTxF(fs ...NoTxFunc) StepFunc + func Tx(cmds ...SQLCommand) StepFunc + func TxF(fs ...TxFunc) StepFunc + type StepInfo interface + From func() Version + Name func() string + To func() Version + type Stepper interface + Check func(Version) error + Down func(Version) (StepInfo, StepFunc, error) + Len func() int + Name func(ID int) (string, error) + Up func(Version) (StepInfo, StepFunc, error) + Version func(ID int) (Version, error) + type Steps struct + func NewSteps(name string) *Steps + func (s *Steps) Append(name string, up StepFunc, down StepFunc) error + func (s *Steps) Check(v Version) error + func (s *Steps) Down(v Version) (nfo StepInfo, f StepFunc, err error) + func (s *Steps) Len() int + func (s *Steps) Name(ID int) (name string, err error) + func (s *Steps) Up(v Version) (nfo StepInfo, f StepFunc, err error) + func (s *Steps) Version(ID int) (v Version, err error) + type TxFunc func(tx SQLTx, info StepInfo, dryRun bool, log Logger) error + type Version struct + Checksum [32]byte + ID int + func MakeVersion(id int, checksum string) (Version, error) + func (v Version) ChecksumString() string + func (v Version) String() string