Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // TableName specifies the name of the table that keeps track of which migrations have been applied. // Defaults to "migration". TableName string // LockTableName specifies the name of the table that makes sure only one instance of go-migration runs at the // same time on the same database. // Defaults to "migration_lock". LockTableName string // MigrationFolder specifies the location of migration sql files. // Defaults to "db/migrations". MigrationFolder string // LockTimeoutMinutes specifies the lock timeout in minutes. // Defaults to 15. LockTimeoutMinutes int }
Config holds migration configuration parameters.
type FSOption ¶ added in v2.1.0
FSOption makes migration use a specific FileSystem, instead of the default. useful with embed, for example.
type FuncMigration ¶ added in v2.2.0
type FuncMigration interface { // Apply should perform the migration. Implementations should not commit // nor rollback the transaction. Apply(db *sql.Tx) error // Filename should declare the file in the migrations dir in which the // migration is implemented. Filename() string }
FuncMigration can be implemented by apps relying on go-migration to allow for code based migrations. If a call to Apply returns with a non-nil error, the migration process will be interrupted and a rollback will occur.
type FuncMigrationOption ¶ added in v2.2.0
type FuncMigrationOption struct { // Migration is the FuncMigration that will be applied by a call to its // Apply func. The migration will be applied using the same ordering as in // the .sql file case, using the ordered strings index of the filename // supplied. Migration FuncMigration }
FuncMigrationOption should be used if project requires code based migrations, implementations should be located in the migrations directory of the project alongside .sql migration files and the same naming convention is to be used.
type LoggerOption ¶
LoggerOption is used to define a custom logger to be used in the go-migration lib.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to configure go-migration in different ways. Please refer to the examples.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the db migration service.
type SlogOption ¶ added in v2.3.0
SlogOption is used to define a custom slog logger to be used in the go-migration lib.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
basic
command
|
|
code-based
command
|
|
config
command
|
|
embed
command
|
|
slog
command
|
|
zap
command
|
|
test
|
|
code-based
nolint:revive No docs for test migration implementations.
|
nolint:revive No docs for test migration implementations. |
code-based-fail
nolint:revive No docs for test migration implementations.
|
nolint:revive No docs for test migration implementations. |