Releases: pressly/goose
v3.21.1
- Add
GetVersions
method togoose.Provider
, returns the current (max db) version and the latest
(max filesystem) version. (#756) - Clarify
GetLatestVersion
method MUST returnErrVersionNotFound
if no latest migration is
found. Previously it was returning a -1 and nil error, which was inconsistent with the rest of the
API surface. - Add
GetLatestVersion
implementations to all existing dialects. This is an optimization to avoid
loading all migrations when only the latest version is needed. This uses themax
function in SQL
to get the latest version_id irrespective of the order of applied migrations.- Refactor existing portions of the code to use the new
GetLatestVersion
method.
- Refactor existing portions of the code to use the new
Note, v3.21.0
was retracted due to a reported user issue #779 with Go modules and replace directives when using go run
, hence the patch bump to v3.21.1
.
v3.21.0
v3.20.0
What's Changed
- Expand the
Store
interface by adding aGetLatestVersion
method and make the interface public. - Add a (non-blocking) method to check if there are pending migrations to the
goose.Provider
(#751):
func (p *Provider) HasPending(context.Context) (bool, error) {}
Note
The underlying implementation does not respect the SessionLocker
(if one is enabled) and can
be used to check for pending migrations without blocking or being blocked by other operations.
- The methods
.Up
,.UpByOne
, and.UpTo
fromgoose.Provider
will invoke.HasPending
before
acquiring a lock withSessionLocker
(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 #507 (comment) and #751. - Move integration tests to
./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.
v3.19.2
- Remove duckdb support. The driver uses Cgo and we've decided to remove it until we can find a
better solution. If you were using duckdb with goose, please let us know by opening an issue.
v3.19.1
- Fix selecting dialect for
redshift
- Add
GOOSE_MIGRATION_DIR
documentation - Bump github.com/opencontainers/runc to
v1.1.12
(security fix) - Update CI tests for go1.22
- Make goose annotations case-insensitive
- All
-- +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.
- All
New Contributors
- @jbking made their first contribution in #692
- @JosefuMealsom made their first contribution in #697
- @dpeckett made their first contribution in #696 (currently disabled until build is resolved, uses CGO. But thank you for the contribution 😄)
- @obalunenko made their first contribution in #704
v3.18.0
v3.18.0
(current release) the minimum supported Go version is go1.20
New features
-
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 variableREGION
is set tous_east_1
, the following SQL migration
will be substituted toSELECT * 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)
-
Fixes
- Fixed query for list migrations in YDB (#684)
v3.17.0
- Standardised the MIT license (#647)
- Improve provider
Apply()
errors, addErrNotApplied
when attempting to rollback a migration
that has not been previously applied. (#660) - Add
WithDisableGlobalRegistry
option toNewProvider
to disable the global registry. (#645) - Add
-timeout
flag to CLI to set the maximum allowed duration for queries to run. Default remains
no timeout. (#627) - Add optional logging in
Provider
whenWithVerbose
option is supplied. (#668)
⚠️ Potential Breaking Change ⚠️
- Update
goose create
to use UTC time instead of local time. (#242)
v3.16.0
- Added YDB support. (#592)
- Fix sqlserver query to ensure DB version. (#601)
- Allow setting / resetting the global Go migration registry. (#602)
SetGlobalMigrations
andResetGlobalMigrations
functions have been added.- Introduce
NewGoMigration
for constructing Go migrations.
- Add initial implementation of
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:
- Avoid global state
- Make Provider safe to use concurrently
- Unlock (no pun intended) new features, such as database locking
- Make logging configurable
- Better error handling with proper return values
- Double down on Go migrations
- ... and more!
v3.15.1
- Fix regression that prevented registering Go migrations that didn't have the corresponding files
available in the filesystem. (#588)- If Go migrations have been registered globally, but there are no .go files in the filesystem,
always include them. - If Go migrations have been registered, and there are .go files in the filesystem, only
include those migrations. This was the original motivation behind #553. - If there are .go files in the filesystem but not registered, raise an error. This is to
prevent accidentally adding valid looking Go migration files without explicitly registering
them.
- If Go migrations have been registered globally, but there are no .go files in the filesystem,