Files
threshold/internal/db/schema/doc.go
T
Timothy Messier 8caaf3e076 refactor(schema): Add support for migration editions
This refactors the schema package and subpackages to support editions.
An Edition is a collection of sql migrations. A given boundary binary
can have multiple migration editions. The `schema.Manager` is updated to
apply the necessary migrations in the correct order, leveraging an
Edition's priority to determine the order in which the separate Editions
are applied.

The sql migration files are now nested under a directory for the
edition.

This also switches from the generated code to using embed, which
eliminates the need for the `make migrations` target and the generated
code. As such this commit removes the target and generated code.

See:
    https://pkg.go.dev/embed
2021-10-08 06:50:26 -04:00

23 lines
778 B
Go

// Package schema is used to apply sql migrations to modify the state of a
// database instance. It also provides functionality to report on the state of
// a database instance and how it compares with the migration editions in the
// running binary.
//
// This package requires that the migration editions are first registered,
// prior to creating a schema.Manager. This is generally done in an init
// function of another package, i.e.:
//
// //go:embed postgres
// var postgres embed.FS
//
// func init() {
// schema.RegisterEdition("oss", schema.Postgres, postgres, 0)
// }
//
// Then a manager can be created and used to apply the migrations:
//
// m := schema.NewManager(ctx, schema.Postgres, db)
// m.ApplyMigrations()
//
package schema