Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnsupportedDBKind = errors.New("sqlmigration: unsupported database kind")
ErrUnsupportedDBKind indicates the configured database dialect has no migration script or schema lookup query for the supplied Plan.
Functions ¶
func LoadScript ¶
LoadScript returns the DDL script for the given dialect from the supplied embedded FS. Exported so callers that need the SQL text (e.g. integration tests) can re-use the lookup convention.
Types ¶
type Plan ¶
type Plan struct {
// Label is a short, human-readable identifier ("storage",
// "event outbox", ...). Used as the error prefix.
Label string
// Kind is the database dialect.
Kind config.DBKind
// Scripts is the embedded SQL bundle. Run looks up
// "scripts/<kind>.sql" within this FS.
Scripts embed.FS
// ExpectedTables names every table the migration must end up with.
// The migration is skipped when all of them already exist.
ExpectedTables []string
// Pre is an optional list of steps that run before the
// needs-migration probe (e.g. dropping obsolete tables left over
// from earlier schema revisions). Each hook should be idempotent.
Pre []func(ctx context.Context, db orm.DB) error
}
Plan describes one module's migration. Label appears in error messages so logs identify which module is being migrated.
Click to show internal directories.
Click to hide internal directories.