Documentation
¶
Overview ¶
Package dbmigrate runs an embedded goose migration chain against a PostgreSQL database. Every service ships its own chain and its own connection string; what they share is the machinery around goose — the single-connection pool the session lock needs, the advisory lock that serializes concurrent runs, and the error wrapping an operator reads. That machinery lives here so a fix to it reaches every service.
The chain is a plain fs.FS, which is what the embedding package exposes, so a service's store package is a name for its chain and the table that chain books its applied versions in, and nothing more.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownTo ¶
func DownTo(ctx context.Context, dbURL string, chain fs.FS, versionTable string, version int64) ([]int64, error)
DownTo rolls chain back to version, applying the down migration of everything above it, and returns the versions it rolled back. Passing 0 leaves an empty schema.
It is the counterpart of Up: a chain ships down migrations, and a rollback nobody can run is a rollback that does not exist.
Types ¶
type MigrationState ¶
type MigrationState struct {
// Version is the migration's version, the number its file name starts with.
Version int64
// Applied says whether the database has this migration.
Applied bool
}
MigrationState is one migration of a chain and whether the database carries it. It is what answers "which schema is this database on" before code that assumes a newer one is run against it.