A database migration tool. Supports SQL migrations and Go functions.
Store
interface by adding a GetLatestVersion
method and make the interface public.goose.Provider
(#751):func (p *Provider) HasPending(context.Context) (bool, error) {}
[!NOTE]
The underlying implementation does not respect theSessionLocker
(if one is enabled) and can be used to check for pending migrations without blocking or being blocked by other operations.
.Up
, .UpByOne
, and .UpTo
from goose.Provider
will invoke .HasPending
before
acquiring a lock with SessionLocker
(if enabled). This addresses an edge case in
Kubernetes-style deployments where newer pods with long-running migrations prevent older pods -
which have all known migrations applied - from starting up due to an advisory lock. For more
details, refer to https://github.com/pressly/goose/pull/507#discussion_r1266498077 and #751../internal/testing
and make it a separate Go module. This will allow
us to have a cleaner top-level go.mod file and avoid imports unrelated to the goose project. See
integration/README.md
for more details. This shouldn't affect users of the goose library.redshift
GOOSE_MIGRATION_DIR
documentationv1.1.12
(security fix)-- +goose
annotations are now case-insensitive. This means that -- +goose Up
and -- +goose up
are now equivalent. This change was made to improve the user experience and to make the annotations more consistent.⚠️ Note, starting with goose v3.18.0
(current release) the minimum supported Go version is go1.20
Add environment variable substitution for SQL migrations. (#604)
This feature is disabled by default, and can be enabled by adding an annotation to the migration file:
-- +goose ENVSUB ON
When enabled, goose will attempt to substitute environment variables in the SQL migration
queries until the end of the file, or until the annotation -- +goose ENVSUB OFF
is found. For
example, if the environment variable REGION
is set to us_east_1
, the following SQL migration
will be substituted to SELECT * FROM regions WHERE name = 'us_east_1';
-- +goose ENVSUB ON
-- +goose Up
SELECT * FROM regions WHERE name = '${REGION}';
This feature intentionally supports a minimal expansion set; see Supported Expansions in the https://github.com/mfridman/interpolate repository (forked from https://github.com/buildkite/interpolate)
Add native Turso support with libsql driver. (#658)
Apply()
errors, add ErrNotApplied
when attempting to rollback a migration
that has not been previously applied. (#660)WithDisableGlobalRegistry
option to NewProvider
to disable the global registry. (#645)-timeout
flag to CLI to set the maximum allowed duration for queries to run. Default remains
no timeout. (#627)Provider
when WithVerbose
option is supplied. (#668)goose create
to use UTC time instead of local time. (#242)SetGlobalMigrations
and ResetGlobalMigrations
functions have been added.NewGoMigration
for constructing Go migrations.goose.NewProvider
.🎉 Read more about this new feature here:
https://pressly.github.io/goose/blog/2023/goose-provider/
The motivation behind the Provider was simple - to reduce global state and make goose easier to consume as an imported package.
Here's a quick summary:
sqlparser
to avoid skipping the last statement when it's not terminated with a semicolon
within a StatementBegin/End block. (#580)go1.21
to the CI matrix.go1.19
.AddMigrationNoTxContext
was registering the wrong source because it skipped
too many frames. #572sqlparser
where the last up statement may be ignored if it's
unterminated with a semicolon and followed by a -- +goose Down
annotation.Logger
interface to Printf
and Fatalf
methods only. Projects that have previously
implemented the Logger
interface should not be affected, and can remove unused methods.