Documentation
¶
Index ¶
- func Cmd(cmd string, args ...any) migrate.SQLCommand
- func NewSteps(name string) *migrate.Steps
- func NoTxF(fs ...NoTxFunc) migrate.StepFunc
- func Open(sourceName string, options ...Option) (migrate.SQLDB, error)
- func Tx(cmds ...migrate.SQLCommand) migrate.StepFunc
- type Logger
- type Migrator
- type NoTxFunc
- type Option
- type SQLDB
- type SQLTx
- type StepFunc
- type StepInfo
- type Steps
- type TxFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cmd ¶
func Cmd(cmd string, args ...any) migrate.SQLCommand
Cmd is a function simplifying the creation of a Command.
func NewSteps ¶ added in v0.0.1
NewSteps instantiates a new migration step sequence. The name should not be empty and ideally unique to the database as it is used to compute the root checksum identifying the database.
func NoTxF ¶
NoTxF returns a migration step function that executes the user provided functions in sequence without a wrapping transaction. It terminates as soon as a function returns an error. It doesn't execute any function when dryRun is true. The pseudo error ErrCancel is treated as ErrAbort as operations can't be cancelled and database version remains v1.
Use with care as any error in the function may leave the database is an undefined state.
func Tx ¶
func Tx(cmds ...migrate.SQLCommand) migrate.StepFunc
Tx returns a migration step function that executes all the SQL commands in sequence wrapped in a transaction. The execution stops and rolls back as soon as an error is returned by one of the commands. It is also rolled back when dryRun is true.
Types ¶
type Option ¶
type Option func(*config)
Option function.
func WithTableName ¶
WithTableName changes the default version table name.
type StepFunc ¶
StepFunc is a migration step function.
func NoTx ¶
func NoTx(cmds ...migrate.SQLCommand) StepFunc
NoTx returns a migration step function that executes the SQL commands in sequence without a wrapping transaction. It terminates as soon as a command returns an error. It doesn't execute any cmds when dryRun is true.
func TxF ¶
TxF returns a migration step function that executes all the user provided functions in sequence wrapped in a transaction. The execution stops and rolls back as soon as an error is returned by one of the function and the step function returns the error.
A user function may return the ErrAbort pseudo error to force a termination of the function execution and the AllUp or AllDown execution which will return the ErrAbort error. To force a roll back of the transaction without terminating the execution of subsequent functions and migration steps, it must return the ErrCancel pseudo error. The migration step function will return nil as error.