diff --git a/CHANGELOG.md b/CHANGELOG.md index fb3485a82..f006d5fac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -- Update `WithDisableGlobalRegistry` behavior (#783). If set, this will ignore globally-registered - migrations instead of raising an error. Specifically, the following check is removed: +- Minimum Go version is now 1.21 +- Add Unwrap to PartialError (#815) +- Update `WithDisableGlobalRegistry` behavior (#783). When set, this will ignore globally-registered + migrationse entirely instead of the previous behavior of raising an error. Specifically, the + following check is removed: ```go if len(global) > 0 { @@ -18,7 +21,24 @@ if len(global) > 0 { This enables creating isolated goose provider(s) in legacy environments where global migrations may be registered. Without updating this behavior, it would be impossible to use -`WithDisableGlobalRegistry` in combination with `WithGoMigrations`. +`WithDisableGlobalRegistry` in combination with provider-scoped `WithGoMigrations`. + +- Postgres, updated schema to use identity instead of serial and make `tstamp` not nullable (#556) + +```diff +- id serial NOT NULL, ++ id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + +- tstamp timestamp NULL default now(), ++ tstamp timestamp NOT NULL DEFAULT now() +``` + +- MySQL, updated schema to not use SERIAL alias (#816) + +```diff +- id serial NOT NULL, ++ id bigint(20) unsigned NOT NULL AUTO_INCREMENT, +``` ## [v3.21.1] diff --git a/README.md b/README.md index 041e99b50..86b4302cb 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ Examples: GOOSE_DRIVER=postgres GOOSE_DBSTRING="user=postgres dbname=postgres sslmode=disable" goose status GOOSE_DRIVER=mysql GOOSE_DBSTRING="user:password@/dbname" goose status GOOSE_DRIVER=redshift GOOSE_DBSTRING="postgres://user:password@qwerty.us-east-1.redshift.amazonaws.com:5439/db" goose status + GOOSE_DRIVER=clickhouse GOOSE_DBSTRING="clickhouse://user:password@qwerty.clickhouse.cloud:9440/dbname?secure=true&skip_verify=false" goose status Options: diff --git a/cmd/goose/main.go b/cmd/goose/main.go index e18b913f0..8a8f86f92 100644 --- a/cmd/goose/main.go +++ b/cmd/goose/main.go @@ -279,6 +279,7 @@ Examples: GOOSE_DRIVER=mysql GOOSE_DBSTRING="user:password@/dbname" goose status GOOSE_DRIVER=redshift GOOSE_DBSTRING="postgres://user:password@qwerty.us-east-1.redshift.amazonaws.com:5439/db" goose status GOOSE_DRIVER=turso GOOSE_DBSTRING="libsql://dbname.turso.io?authToken=token" goose status + GOOSE_DRIVER=clickhouse GOOSE_DBSTRING="clickhouse://user:password@qwerty.clickhouse.cloud:9440/dbname?secure=true&skip_verify=false" goose status Options: ` diff --git a/database/store.go b/database/store.go index 0c7e44de8..ff0e714a8 100644 --- a/database/store.go +++ b/database/store.go @@ -27,8 +27,7 @@ type Store interface { // Tablename is the name of the version table. This table is used to record applied migrations // and must not be an empty string. Tablename() string - // CreateVersionTable creates the version table, which is used to track migrations. When - // creating this table, the implementation MUST also insert a row for the initial version (0). + // CreateVersionTable creates the version table, which is used to track migrations. CreateVersionTable(ctx context.Context, db DBTxConn) error // Insert a version id into the version table. Insert(ctx context.Context, db DBTxConn, req InsertRequest) error diff --git a/internal/dialect/dialectquery/mysql.go b/internal/dialect/dialectquery/mysql.go index b14ef392b..1ce165cef 100644 --- a/internal/dialect/dialectquery/mysql.go +++ b/internal/dialect/dialectquery/mysql.go @@ -8,7 +8,7 @@ var _ Querier = (*Mysql)(nil) func (m *Mysql) CreateTable(tableName string) string { q := `CREATE TABLE %s ( - id serial NOT NULL, + id bigint(20) unsigned NOT NULL AUTO_INCREMENT, version_id bigint NOT NULL, is_applied boolean NOT NULL, tstamp timestamp NULL default now(), diff --git a/internal/dialect/dialectquery/postgres.go b/internal/dialect/dialectquery/postgres.go index 0faadf5e4..2def6c6ca 100644 --- a/internal/dialect/dialectquery/postgres.go +++ b/internal/dialect/dialectquery/postgres.go @@ -8,11 +8,10 @@ var _ Querier = (*Postgres)(nil) func (p *Postgres) CreateTable(tableName string) string { q := `CREATE TABLE %s ( - id serial NOT NULL, + id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, version_id bigint NOT NULL, is_applied boolean NOT NULL, - tstamp timestamp NULL default now(), - PRIMARY KEY(id) + tstamp timestamp NOT NULL DEFAULT now() )` return fmt.Sprintf(q, tableName) } diff --git a/provider_errors.go b/provider_errors.go index 79a2cda2b..718bcbec8 100644 --- a/provider_errors.go +++ b/provider_errors.go @@ -42,3 +42,7 @@ func (e *PartialError) Error() string { e.Failed.Source.Type, e.Failed.Source.Version, e.Err, ) } + +func (e *PartialError) Unwrap() error { + return e.Err +} diff --git a/provider_test.go b/provider_test.go index 1b201b413..82676043e 100644 --- a/provider_test.go +++ b/provider_test.go @@ -35,7 +35,6 @@ func TestProvider(t *testing.T) { check.Equal(t, len(sources), 2) check.Equal(t, sources[0], newSource(goose.TypeSQL, "001_foo.sql", 1)) check.Equal(t, sources[1], newSource(goose.TypeSQL, "002_bar.sql", 2)) - } var ( @@ -76,3 +75,10 @@ ALTER TABLE my_foo DROP COLUMN timestamp; ALTER TABLE my_foo RENAME TO foo; ` ) + +func TestPartialErrorUnwrap(t *testing.T) { + err := &goose.PartialError{Err: goose.ErrNoCurrentVersion} + + got := errors.Is(err, goose.ErrNoCurrentVersion) + check.Bool(t, got, true) +}