migrations

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

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.

View Source
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

func CheckVersion(driver string, dbVersion int64) error

CheckVersion returns a *SchemaTooNewError when dbVersion is above MaxVersion(driver).

func MaxVersion added in v0.4.0

func MaxVersion(driver string) (int64, error)

MaxVersion is the highest migration embedded for driver ("sqlite" or "postgres").

func NewProvider added in v0.4.0

func NewProvider(db *sql.DB, driver string) (*goose.Provider, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL