Documentation
¶
Overview ¶
Package migrations embeds the SQL migration files goose uses to manage the sqi-server state store schema, one set per driver: FS for SQLite (this directory, from 00001) and PostgresFS for PostgreSQL (the postgres subdirectory, from 00037_baseline.sql). Version N is the same schema on both backends, so every schema change after 00037 ships as a pair.
NewProvider returns a goose provider over a database and its driver's set. The provider carries its own dialect and file system, so production code never touches goose's package-level SetBaseFS/SetDialect state: the SQLite and PostgreSQL stores' AutoMigrate and the "sqi-server migrate" subcommands all go through it. Embedding means the migration files ship inside the binary and need not be present on disk at runtime.
Migration files follow the goose naming convention:
<version>_<description>.sql
where <version> is a zero-padded integer and each file contains "-- +goose Up" and "-- +goose Down" sections.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSchemaTooNew = errors.New("database schema is newer than this sqi-server")
ErrSchemaTooNew means the database was migrated by a newer sqi-server than this one. sqi's schema is forward-only: the way back is restoring the backup taken before the upgrade, with the old binary.
var FS = fsutil.HideAppleDouble(raw)
FS wraps the raw embed, hiding macOS AppleDouble companion files ("._x.sql") from goose. See internal/fsutil for why they appear and what they break.
var PostgresFS = fsutil.HideAppleDouble(mustSub(rawPostgres, "postgres"))
PostgresFS holds the PostgreSQL migration set, rooted at its own directory. It starts at 00037_baseline.sql: version N is the same schema on both backends.
Functions ¶
func CheckVersion ¶ added in v0.4.0
CheckVersion returns a *SchemaTooNewError when dbVersion is above MaxVersion(driver).
func MaxVersion ¶ added in v0.4.0
MaxVersion is the highest migration embedded for driver ("sqlite" or "postgres").
func NewProvider ¶ added in v0.4.0
NewProvider returns a goose provider for driver ("sqlite" or "postgres") over db and that driver's migration set. A provider keeps its dialect and file system to itself, unlike goose's package-level SetDialect/SetBaseFS, so a SQLite and a PostgreSQL store can migrate in one process at once.
Types ¶
type SchemaTooNewError ¶ added in v0.4.0
type SchemaTooNewError struct{ DBVersion, BinaryVersion int64 }
SchemaTooNewError carries both versions.
func (*SchemaTooNewError) Error ¶ added in v0.4.0
func (e *SchemaTooNewError) Error() string
func (*SchemaTooNewError) Is ¶ added in v0.4.0
func (*SchemaTooNewError) Is(target error) bool
Is makes errors.Is(err, ErrSchemaTooNew) true.