1# Changelog
2
3All notable changes to this project will be documented in this file.
4
5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
6adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
8## [Unreleased]
9
10## [v3.24.2]
11
12- Add `TableExists` table existence check for the mysql dialect (#895)
13- Upgrade **minimum Go version to 1.23**
14- Various dependency updates
15
16## [v3.24.1]
17
18- Fix regression (`v3.23.1` and `v3.24.0`) in postgres migration table existence check for
19 non-default schema. (#882, #883, #884).
20
21## [v3.24.0]
22
23- Add support for loading environment variables from `.env` files, enabled by default.
24 - The default file name is `.env`, but can be changed with the `-env=<filename>` flag.
25 - To disable this feature, set `-env=none`.
26
27## [v3.23.1]
28
29- Store implementations can **optionally** implement the `TableExists` method to provide optimized
30 table existence checks (#860)
31 - Default postgres Store implementation updated to use `pg_tables` system catalog, more to follow
32 - Backward compatible change - existing implementations will continue to work without modification
33
34```go
35TableExists(ctx context.Context, db database.DBTxConn) (bool, error)
36```
37
38## [v3.23.0]
39
40- Add `WithLogger` to `NewProvider` to allow custom loggers (#833)
41- Update Provider `WithVerbose` behavior to log all SQL statements (#851)
42- Upgrade dependencies and rebuild binaries with latest Go version (`go1.23.3`)
43
44## [v3.22.1]
45
46- Upgrade dependencies and rebuild binaries with latest Go version (`go1.23.1`)
47
48## [v3.22.0]
49
50- Minimum Go version is now 1.21
51- Add Unwrap to PartialError (#815)
52- Allow flags anywhere on the CLI (#814)
53
54`goose` uses the default Go `flag` parsing library, which means flags **must** be defined before the
55first positional argument. We've updated this behavior to allow flags to be defined anywhere. For
56more details, see [blog post](https://mfridman.com/blog/2024/allowing-flags-anywhere-on-the-cli/).
57
58- Update `WithDisableGlobalRegistry` behavior (#783). When set, this will ignore globally-registered
59 migrationse entirely instead of the previous behavior of raising an error. Specifically, the
60 following check is removed:
61
62```go
63if len(global) > 0 {
64 return nil, errors.New("global registry disabled, but provider has registered go migrations")
65}
66```
67
68This enables creating isolated goose provider(s) in legacy environments where global migrations may
69be registered. Without updating this behavior, it would be impossible to use
70`WithDisableGlobalRegistry` in combination with provider-scoped `WithGoMigrations`.
71
72- Postgres, updated schema to use identity instead of serial and make `tstamp` not nullable (#556)
73
74```diff
75- id serial NOT NULL,
76+ id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
77
78- tstamp timestamp NULL default now(),
79+ tstamp timestamp NOT NULL DEFAULT now()
80```
81
82- MySQL, updated schema to not use SERIAL alias (#816)
83
84```diff
85- id serial NOT NULL,
86+ id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
87```
88
89## [v3.21.1]
90
91- Add `GetVersions` method to `goose.Provider`, returns the current (max db) version and the latest
92 (max filesystem) version. (#756)
93- Clarify `GetLatestVersion` method MUST return `ErrVersionNotFound` if no latest migration is
94 found. Previously it was returning a -1 and nil error, which was inconsistent with the rest of the
95 API surface.
96
97- Add `GetLatestVersion` implementations to all existing dialects. This is an optimization to avoid
98 loading all migrations when only the latest version is needed. This uses the `max` function in SQL
99 to get the latest version_id irrespective of the order of applied migrations.
100 - Refactor existing portions of the code to use the new `GetLatestVersion` method.
101
102## [v3.21.0]
103
104- Retracted. Broken release, please use v3.21.1 instead.
105
106## [v3.20.0]
107
108- Expand the `Store` interface by adding a `GetLatestVersion` method and make the interface public.
109- Add a (non-blocking) method to check if there are pending migrations to the `goose.Provider`
110 (#751):
111
112```go
113func (p *Provider) HasPending(context.Context) (bool, error) {}
114```
115
116The underlying implementation **does not respect the `SessionLocker`** (if one is enabled) and can
117be used to check for pending migrations without blocking or being blocked by other operations.
118
119- The methods `.Up`, `.UpByOne`, and `.UpTo` from `goose.Provider` will invoke `.HasPending` before
120 acquiring a lock with `SessionLocker` (if enabled). This addresses an edge case in
121 Kubernetes-style deployments where newer pods with long-running migrations prevent older pods -
122 which have all known migrations applied - from starting up due to an advisory lock. For more
123 details, refer to https://github.com/pressly/goose/pull/507#discussion_r1266498077 and #751.
124- Move integration tests to `./internal/testing` and make it a separate Go module. This will allow
125 us to have a cleaner top-level go.mod file and avoid imports unrelated to the goose project. See
126 [integration/README.md](https://github.com/pressly/goose/blob/d0641b5bfb3bd5d38d95fe7a63d7ddf2d282234d/internal/testing/integration/README.md)
127 for more details. This shouldn't affect users of the goose library.
128
129## [v3.19.2] - 2024-03-13
130
131- Remove duckdb support. The driver uses Cgo and we've decided to remove it until we can find a
132 better solution. If you were using duckdb with goose, please let us know by opening an issue.
133
134## [v3.19.1] - 2024-03-11
135
136- Fix selecting dialect for `redshift`
137- Add `GOOSE_MIGRATION_DIR` documentation
138- Bump github.com/opencontainers/runc to `v1.1.12` (security fix)
139- Update CI tests for go1.22
140- Make goose annotations case-insensitive
141 - All `-- +goose` annotations are now case-insensitive. This means that `-- +goose Up` and `--
142+goose up` are now equivalent. This change was made to improve the user experience and to make the
143 annotations more consistent.
144
145## [v3.19.0] - 2024-03-11
146
147- Use [v3.19.1] instead. This was tagged but not released and does not contain release binaries.
148
149## [v3.18.0] - 2024-01-31
150
151- Add environment variable substitution for SQL migrations. (#604)
152
153 - This feature is **disabled by default**, and can be enabled by adding an annotation to the
154 migration file:
155
156 ```sql
157 -- +goose ENVSUB ON
158 ```
159
160 - When enabled, goose will attempt to substitute environment variables in the SQL migration
161 queries until the end of the file, or until the annotation `-- +goose ENVSUB OFF` is found. For
162 example, if the environment variable `REGION` is set to `us_east_1`, the following SQL migration
163 will be substituted to `SELECT * FROM regions WHERE name = 'us_east_1';`
164
165 ```sql
166 -- +goose ENVSUB ON
167 -- +goose Up
168 SELECT * FROM regions WHERE name = '${REGION}';
169 ```
170
171- Add native [Turso](https://turso.tech/) support with libsql driver. (#658)
172
173- Fixed query for list migrations in YDB (#684)
174
175## [v3.17.0] - 2023-12-15
176
177- Standardised the MIT license (#647)
178- Improve provider `Apply()` errors, add `ErrNotApplied` when attempting to rollback a migration
179 that has not been previously applied. (#660)
180- Add `WithDisableGlobalRegistry` option to `NewProvider` to disable the global registry. (#645)
181- Add `-timeout` flag to CLI to set the maximum allowed duration for queries to run. Default remains
182 no timeout. (#627)
183- Add optional logging in `Provider` when `WithVerbose` option is supplied. (#668)
184
185⚠️ Potential Breaking Change ⚠️
186
187- Update `goose create` to use UTC time instead of local time. (#242)
188
189## [v3.16.0] - 2023-11-12
190
191- Added YDB support. (#592)
192- Fix sqlserver query to ensure DB version. (#601)
193- Allow setting / resetting the global Go migration registry. (#602)
194 - `SetGlobalMigrations` and `ResetGlobalMigrations` functions have been added.
195 - Introduce `NewGoMigration` for constructing Go migrations.
196- Add initial implementation of `goose.NewProvider`.
197
198🎉 Read more about this new feature here:
199
200https://pressly.github.io/goose/blog/2023/goose-provider/
201
202The motivation behind the Provider was simple - to reduce global state and make goose easier to
203consume as an imported package.
204
205Here's a quick summary:
206
207- Avoid global state
208- Make Provider safe to use concurrently
209- Unlock (no pun intended) new features, such as database locking
210- Make logging configurable
211- Better error handling with proper return values
212- Double down on Go migrations
213- ... and more!
214
215## [v3.15.1] - 2023-10-10
216
217- Fix regression that prevented registering Go migrations that didn't have the corresponding files
218 available in the filesystem. (#588)
219 - If Go migrations have been registered globally, but there are no .go files in the filesystem,
220 **always include** them.
221 - If Go migrations have been registered, and there are .go files in the filesystem, **only
222 include** those migrations. This was the original motivation behind #553.
223 - If there are .go files in the filesystem but not registered, **raise an error**. This is to
224 prevent accidentally adding valid looking Go migration files without explicitly registering
225 them.
226
227## [v3.15.0] - 2023-08-12
228
229- Fix `sqlparser` to avoid skipping the last statement when it's not terminated with a semicolon
230 within a StatementBegin/End block. (#580)
231- Add `**go1.21**` to the CI matrix.
232- Bump minimum version of module in go.mod to `go1.19`.
233- Fix version output when installing pre-built binaries (#585).
234
235## [v3.14.0] - 2023-07-26
236
237- Filter registered Go migrations from the global map with corresponding .go files from the
238 filesystem.
239 - The code previously assumed all .go migrations would be in the same folder, so this should not
240 be a breaking change.
241 - See #553 for more details
242- Improve output log message for applied up migrations. #562
243- Fix an issue where `AddMigrationNoTxContext` was registering the wrong source because it skipped
244 too many frames. #572
245- Improve binary version output when using go install.
246
247## [v3.13.4] - 2023-07-07
248
249- Fix pre-built binary versioning and make small improvements to GoReleaser config.
250- Fix an edge case in the `sqlparser` where the last up statement may be ignored if it's
251 unterminated with a semicolon and followed by a `-- +goose Down` annotation.
252- Trim `Logger` interface to `Printf` and `Fatalf` methods only. Projects that have previously
253 implemented the `Logger` interface should not be affected, and can remove unused methods.
254
255## [v3.13.1] - 2023-07-03
256
257- Add pre-built binaries with GoReleaser and update the build process.
258
259## [v3.13.0] - 2023-06-29
260
261- Add a changelog to the project, based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
262- Update go.mod and retract all `v3.12.X` tags. They were accidentally pushed and contain a
263 reference to the wrong Go module.
264- Fix `up` and `up -allowing-missing` behavior.
265- Fix empty version in log output.
266- Add new `context.Context`-aware functions and methods, for both sql and go migrations.
267- Return error when no migration files found or dir is not a directory.
268
269[Unreleased]: https://github.com/pressly/goose/compare/v3.24.2...HEAD
270[v3.24.2]: https://github.com/pressly/goose/compare/v3.24.1...v3.24.2
271[v3.24.1]: https://github.com/pressly/goose/compare/v3.24.0...v3.24.1
272[v3.24.0]: https://github.com/pressly/goose/compare/v3.23.1...v3.24.0
273[v3.23.1]: https://github.com/pressly/goose/compare/v3.23.0...v3.23.1
274[v3.23.0]: https://github.com/pressly/goose/compare/v3.22.1...v3.23.0
275[v3.22.1]: https://github.com/pressly/goose/compare/v3.22.0...v3.22.1
276[v3.22.0]: https://github.com/pressly/goose/compare/v3.21.1...v3.22.0
277[v3.21.1]: https://github.com/pressly/goose/compare/v3.20.0...v3.21.1
278[v3.21.0]: https://github.com/pressly/goose/compare/v3.20.0...v3.21.0
279[v3.20.0]: https://github.com/pressly/goose/compare/v3.19.2...v3.20.0
280[v3.19.2]: https://github.com/pressly/goose/compare/v3.19.1...v3.19.2
281[v3.19.1]: https://github.com/pressly/goose/compare/v3.19.0...v3.19.1
282[v3.19.0]: https://github.com/pressly/goose/compare/v3.18.0...v3.19.0
283[v3.18.0]: https://github.com/pressly/goose/compare/v3.17.0...v3.18.0
284[v3.17.0]: https://github.com/pressly/goose/compare/v3.16.0...v3.17.0
285[v3.16.0]: https://github.com/pressly/goose/compare/v3.15.1...v3.16.0
286[v3.15.1]: https://github.com/pressly/goose/compare/v3.15.0...v3.15.1
287[v3.15.0]: https://github.com/pressly/goose/compare/v3.14.0...v3.15.0
288[v3.14.0]: https://github.com/pressly/goose/compare/v3.13.4...v3.14.0
289[v3.13.4]: https://github.com/pressly/goose/compare/v3.13.1...v3.13.4
290[v3.13.1]: https://github.com/pressly/goose/compare/v3.13.0...v3.13.1
291[v3.13.0]: https://github.com/pressly/goose/releases/tag/v3.13.0