Skip to content

Commit

Permalink
Merge branch 'master' into mf/parsing-flags
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman committed Sep 3, 2024
2 parents 7028417 + 31799a9 commit 1ed67d7
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 10 deletions.
26 changes: 23 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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]

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]:5439/db" goose status
GOOSE_DRIVER=clickhouse GOOSE_DBSTRING="clickhouse://user:[email protected]:9440/dbname?secure=true&skip_verify=false" goose status
Options:
Expand Down
1 change: 1 addition & 0 deletions cmd/goose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ Examples:
GOOSE_DRIVER=mysql GOOSE_DBSTRING="user:password@/dbname" goose status
GOOSE_DRIVER=redshift GOOSE_DBSTRING="postgres://user:[email protected]:5439/db" goose status
GOOSE_DRIVER=turso GOOSE_DBSTRING="libsql://dbname.turso.io?authToken=token" goose status
GOOSE_DRIVER=clickhouse GOOSE_DBSTRING="clickhouse://user:[email protected]:9440/dbname?secure=true&skip_verify=false" goose status
Options:
`
Expand Down
3 changes: 1 addition & 2 deletions database/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/dialect/dialectquery/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
5 changes: 2 additions & 3 deletions internal/dialect/dialectquery/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 4 additions & 0 deletions provider_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 7 additions & 1 deletion provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
}

0 comments on commit 1ed67d7

Please sign in to comment.