Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrIrreversible = errors.New("migration is irreversible")
)
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column[T any] struct { // contains filtered or unexported fields }
Column represents the configuration of a column in a table.
type Dialect ¶
type Dialect struct {
// contains filtered or unexported fields
}
Dialect represents an SQL dialect. Dialects are comparable, and the instances of this struct returned by the various functions in this package are guaranteed to always be equal to the result of another call to the same function.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index represents the configuration of an index in a table.
type M ¶
type M struct {
// contains filtered or unexported fields
}
M is a type passed to Migrate functions to configure the migration.
func (*M) CreateTable ¶
CreateTable creates a new table using a configuration determined by f.
func (*M) Require ¶
Require marks other migrations as being dependencies of this one. In other words, the named migrations should be applied before this one is.
Calling this function more than once is equivalent to calling it once with all of the same arguments.
The provided migration names should be the name of the migration function minus the "Migrate" prefix. For example,
func MigrateFirst(m *migration.M) {}
func MigrateSecond(m *migration.M) {
// MigrateSecond depends on MigrateFirst.
m.Require("First")
}
type MigrationFunc ¶
type MigrationFunc func(m *M)
MigrationFunc is the signature matched by functions that define migrations.
type MigrationPlan ¶
type MigrationPlan struct {
// contains filtered or unexported fields
}
MigrationPlan represents a migration plan generated by the Migrate functions. It is intended for internal use.
func PlanUp ¶
func PlanUp(ctx context.Context, db *sql.DB, funcs map[string]MigrationFunc) (*MigrationPlan, error)
PlanUp produces a migration plan that runs all of the migrations, moving the database to the latest schema. It is intended for internal use.
func PlanUpTo ¶
func PlanUpTo(ctx context.Context, db *sql.DB, funcs map[string]MigrationFunc, target string) (*MigrationPlan, error)
func (*MigrationPlan) Steps ¶
func (m *MigrationPlan) Steps() []string
Steps returns the names of the migrations that will be run in the order that they will be run in. Note that this list includes migrations that might be skipped because they've already been run previously.