diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fbde0204f..c339251cf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21.x" + go-version: "1.22.x" - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: version: latest @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ["1.20.x", "1.21.x"] + go: ["1.21.x", "1.22.x"] steps: - uses: actions/checkout@v4 @@ -68,7 +68,7 @@ jobs: ruby-version: 2.7 - uses: actions/setup-go@v5 with: - go-version: "1.21.x" + go-version: "1.22.x" - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 diff --git a/.golangci.yml b/.golangci.yml index 0419e32be..55401a171 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ run: linters: enable: #- golint - - interfacer + #- interfacer - unconvert #- dupl - goconst diff --git a/Dockerfile b/Dockerfile index 116c0ff27..4635e5cf5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine3.19 AS builder +FROM golang:1.22-alpine3.19 AS builder ARG VERSION RUN apk add --no-cache git gcc musl-dev make diff --git a/README.md b/README.md index 359c7b3ab..975348685 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Coverage Status](https://img.shields.io/coveralls/github/golang-migrate/migrate/master.svg)](https://coveralls.io/github/golang-migrate/migrate?branch=master) [![packagecloud.io](https://img.shields.io/badge/deb-packagecloud.io-844fec.svg)](https://packagecloud.io/golang-migrate/migrate?filter=debs) [![Docker Pulls](https://img.shields.io/docker/pulls/migrate/migrate.svg)](https://hub.docker.com/r/migrate/migrate/) -![Supported Go Versions](https://img.shields.io/badge/Go-1.20%2C%201.21-lightgrey.svg) +![Supported Go Versions](https://img.shields.io/badge/Go-1.21%2C%201.22-lightgrey.svg) [![GitHub Release](https://img.shields.io/github/release/golang-migrate/migrate.svg)](https://github.com/golang-migrate/migrate/releases) [![Go Report Card](https://goreportcard.com/badge/github.com/golang-migrate/migrate/v4)](https://goreportcard.com/report/github.com/golang-migrate/migrate/v4) @@ -43,7 +43,7 @@ Database drivers run migrations. [Add a new database?](database/driver.go) * [ClickHouse](database/clickhouse) * [Firebird](database/firebird) * [MS SQL Server](database/sqlserver) -* [RQLite](database/rqlite) +* [rqlite](database/rqlite) ### Database URLs @@ -174,7 +174,7 @@ Each migration has an up and down migration. [Why?](FAQ.md#why-two-separate-file ## Coming from another db migration tool? Check out [migradaptor](https://github.com/musinit/migradaptor/). -*Note: migradaptor is not affliated or supported by this project* +*Note: migradaptor is not affiliated or supported by this project* ## Versions diff --git a/database/cassandra/cassandra_test.go b/database/cassandra/cassandra_test.go index 87d21d9a1..84af2853e 100644 --- a/database/cassandra/cassandra_test.go +++ b/database/cassandra/cassandra_test.go @@ -61,6 +61,20 @@ func isReady(ctx context.Context, c dktest.ContainerInfo) bool { } func Test(t *testing.T) { + t.Run("test", test) + t.Run("testMigrate", testMigrate) + + t.Cleanup(func() { + for _, spec := range specs { + t.Log("Cleaning up ", spec.ImageName) + if err := spec.Cleanup(); err != nil { + t.Error("Error removing ", spec.ImageName, "error:", err) + } + } + }) +} + +func test(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.Port(9042) if err != nil { @@ -81,7 +95,7 @@ func Test(t *testing.T) { }) } -func TestMigrate(t *testing.T) { +func testMigrate(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.Port(9042) if err != nil { diff --git a/database/clickhouse/README.md b/database/clickhouse/README.md index a3cea9298..9357efcfd 100644 --- a/database/clickhouse/README.md +++ b/database/clickhouse/README.md @@ -16,7 +16,7 @@ ## Notes -* The Clickhouse driver does not natively support executing multipe statements in a single query. To allow for multiple statements in a single migration, you can use the `x-multi-statement` param. There are two important caveats: +* The Clickhouse driver does not natively support executing multiple statements in a single query. To allow for multiple statements in a single migration, you can use the `x-multi-statement` param. There are two important caveats: * This mode splits the migration text into separately-executed statements by a semi-colon `;`. Thus `x-multi-statement` cannot be used when a statement in the migration contains a string with a semi-colon. * The queries are not executed in any sort of transaction/batch, meaning you are responsible for fixing partial migrations. * Using the default TinyLog table engine for the schema_versions table prevents backing up the table if using the [clickhouse-backup](https://github.com/AlexAkulov/clickhouse-backup) tool. If backing up the database with make sure the migrations are run with `x-migrations-table-engine=MergeTree`. diff --git a/database/cockroachdb/TUTORIAL.md b/database/cockroachdb/TUTORIAL.md index d8cea6159..f8c9e7c06 100644 --- a/database/cockroachdb/TUTORIAL.md +++ b/database/cockroachdb/TUTORIAL.md @@ -15,7 +15,7 @@ CREATE USER IF NOT EXISTS cockroach; GRANT ALL ON DATABASE example TO cockroach; ``` -When using Migrate CLI we need to pass to database URL. Let's export it to a variable for convienience: +When using Migrate CLI we need to pass to database URL. Let's export it to a variable for convenience: ``` export COCKROACHDB_URL='cockroachdb://cockroach:@localhost:26257/example?sslmode=disable' ``` diff --git a/database/mongodb/mongodb_test.go b/database/mongodb/mongodb_test.go index f15f74113..8823bd9ca 100644 --- a/database/mongodb/mongodb_test.go +++ b/database/mongodb/mongodb_test.go @@ -74,6 +74,22 @@ func isReady(ctx context.Context, c dktest.ContainerInfo) bool { } func Test(t *testing.T) { + t.Run("test", test) + t.Run("testMigrate", testMigrate) + t.Run("testWithAuth", testWithAuth) + t.Run("testLockWorks", testLockWorks) + + t.Cleanup(func() { + for _, spec := range specs { + t.Log("Cleaning up ", spec.ImageName) + if err := spec.Cleanup(); err != nil { + t.Error("Error removing ", spec.ImageName, "error:", err) + } + } + }) +} + +func test(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -99,7 +115,7 @@ func Test(t *testing.T) { }) } -func TestMigrate(t *testing.T) { +func testMigrate(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -125,7 +141,7 @@ func TestMigrate(t *testing.T) { }) } -func TestWithAuth(t *testing.T) { +func testWithAuth(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -180,7 +196,7 @@ func TestWithAuth(t *testing.T) { }) } -func TestLockWorks(t *testing.T) { +func testLockWorks(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -241,6 +257,15 @@ func TestTransaction(t *testing.T) { {ImageName: "mongo:4", Options: dktest.Options{PortRequired: true, ReadyFunc: isReady, Cmd: []string{"mongod", "--bind_ip_all", "--replSet", "rs0"}}}, } + t.Cleanup(func() { + for _, spec := range transactionSpecs { + t.Log("Cleaning up ", spec.ImageName) + if err := spec.Cleanup(); err != nil { + t.Error("Error removing ", spec.ImageName, "error:", err) + } + } + }) + dktesting.ParallelTest(t, transactionSpecs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { diff --git a/database/mysql/README.md b/database/mysql/README.md index 00aca683d..a687b1dd0 100644 --- a/database/mysql/README.md +++ b/database/mysql/README.md @@ -14,7 +14,7 @@ | `port` | | The port to bind to. | | `tls` | | TLS / SSL encrypted connection parameter; see [go-sql-driver](https://github.com/go-sql-driver/mysql#tls). Use any name (e.g. `migrate`) if you want to use a custom TLS config (`x-tls-` queries). | | `x-tls-ca` | | The location of the CA (certificate authority) file. | -| `x-tls-cert` | | The location of the client certicicate file. Must be used with `x-tls-key`. | +| `x-tls-cert` | | The location of the client certificate file. Must be used with `x-tls-key`. | | `x-tls-key` | | The location of the private key file. Must be used with `x-tls-cert`. | | `x-tls-insecure-skip-verify` | | Whether or not to use SSL (true\|false) | diff --git a/database/mysql/mysql.go b/database/mysql/mysql.go index e0e18e7a9..c7e7ef617 100644 --- a/database/mysql/mysql.go +++ b/database/mysql/mysql.go @@ -361,7 +361,7 @@ func (m *Mysql) SetVersion(version int, dirty bool) error { return &database.Error{OrigErr: err, Err: "transaction start failed"} } - query := "DELETE FROM `" + m.config.MigrationsTable + "`" + query := "DELETE FROM `" + m.config.MigrationsTable + "` LIMIT 1" if _, err := tx.ExecContext(context.Background(), query); err != nil { if errRollback := tx.Rollback(); errRollback != nil { err = multierror.Append(err, errRollback) diff --git a/database/mysql/mysql_test.go b/database/mysql/mysql_test.go index 09d95fc9a..0f675d438 100644 --- a/database/mysql/mysql_test.go +++ b/database/mysql/mysql_test.go @@ -391,7 +391,7 @@ func TestURLToMySQLConfig(t *testing.T) { // Not supported yet: https://github.com/go-sql-driver/mysql/issues/591 // {name: "user/password - user with encoded :", // urlStr: "mysql://username%3A:password@tcp(127.0.0.1:3306)/myDB?multiStatements=true", - // expectedDSN: "username::pasword@tcp(127.0.0.1:3306)/myDB?multiStatements=true"}, + // expectedDSN: "username::password@tcp(127.0.0.1:3306)/myDB?multiStatements=true"}, {name: "user/password - user with encoded @", urlStr: "mysql://username%40:password@tcp(127.0.0.1:3306)/myDB?multiStatements=true", expectedDSN: "username@:password@tcp(127.0.0.1:3306)/myDB?multiStatements=true"}, diff --git a/database/postgres/postgres_test.go b/database/postgres/postgres_test.go index 65395cc7e..02bf991b8 100644 --- a/database/postgres/postgres_test.go +++ b/database/postgres/postgres_test.go @@ -85,6 +85,32 @@ func mustRun(t *testing.T, d database.Driver, statements []string) { } func Test(t *testing.T) { + t.Run("test", test) + t.Run("testMigrate", testMigrate) + t.Run("testMultipleStatements", testMultipleStatements) + t.Run("testMultipleStatementsInMultiStatementMode", testMultipleStatementsInMultiStatementMode) + t.Run("testErrorParsing", testErrorParsing) + t.Run("testFilterCustomQuery", testFilterCustomQuery) + t.Run("testWithSchema", testWithSchema) + t.Run("testMigrationTableOption", testMigrationTableOption) + t.Run("testFailToCreateTableWithoutPermissions", testFailToCreateTableWithoutPermissions) + t.Run("testCheckBeforeCreateTable", testCheckBeforeCreateTable) + t.Run("testParallelSchema", testParallelSchema) + t.Run("testPostgresLock", testPostgresLock) + t.Run("testWithInstanceConcurrent", testWithInstanceConcurrent) + t.Run("testWithConnection", testWithConnection) + + t.Cleanup(func() { + for _, spec := range specs { + t.Log("Cleaning up ", spec.ImageName) + if err := spec.Cleanup(); err != nil { + t.Error("Error removing ", spec.ImageName, "error:", err) + } + } + }) +} + +func test(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -106,7 +132,7 @@ func Test(t *testing.T) { }) } -func TestMigrate(t *testing.T) { +func testMigrate(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -132,7 +158,7 @@ func TestMigrate(t *testing.T) { }) } -func TestMultipleStatements(t *testing.T) { +func testMultipleStatements(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -165,7 +191,7 @@ func TestMultipleStatements(t *testing.T) { }) } -func TestMultipleStatementsInMultiStatementMode(t *testing.T) { +func testMultipleStatementsInMultiStatementMode(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -198,7 +224,7 @@ func TestMultipleStatementsInMultiStatementMode(t *testing.T) { }) } -func TestErrorParsing(t *testing.T) { +func testErrorParsing(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -227,7 +253,7 @@ func TestErrorParsing(t *testing.T) { }) } -func TestFilterCustomQuery(t *testing.T) { +func testFilterCustomQuery(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -249,7 +275,7 @@ func TestFilterCustomQuery(t *testing.T) { }) } -func TestWithSchema(t *testing.T) { +func testWithSchema(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -319,7 +345,7 @@ func TestWithSchema(t *testing.T) { }) } -func TestMigrationTableOption(t *testing.T) { +func testMigrationTableOption(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -387,7 +413,7 @@ func TestMigrationTableOption(t *testing.T) { }) } -func TestFailToCreateTableWithoutPermissions(t *testing.T) { +func testFailToCreateTableWithoutPermissions(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -457,7 +483,7 @@ func TestFailToCreateTableWithoutPermissions(t *testing.T) { }) } -func TestCheckBeforeCreateTable(t *testing.T) { +func testCheckBeforeCreateTable(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -534,7 +560,7 @@ func TestCheckBeforeCreateTable(t *testing.T) { }) } -func TestParallelSchema(t *testing.T) { +func testParallelSchema(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -602,7 +628,7 @@ func TestParallelSchema(t *testing.T) { }) } -func TestPostgres_Lock(t *testing.T) { +func testPostgresLock(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -642,7 +668,7 @@ func TestPostgres_Lock(t *testing.T) { }) } -func TestWithInstance_Concurrent(t *testing.T) { +func testWithInstanceConcurrent(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { @@ -685,7 +711,7 @@ func TestWithInstance_Concurrent(t *testing.T) { }) } -func TestWithConnection(t *testing.T) { +func testWithConnection(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { ip, port, err := c.FirstPort() if err != nil { diff --git a/database/sqlserver/sqlserver.go b/database/sqlserver/sqlserver.go index 90e3926df..3cfa48bf9 100644 --- a/database/sqlserver/sqlserver.go +++ b/database/sqlserver/sqlserver.go @@ -263,7 +263,7 @@ func (ss *SQLServer) SetVersion(version int, dirty bool) error { return &database.Error{OrigErr: err, Err: "transaction start failed"} } - query := `TRUNCATE TABLE "` + ss.config.MigrationsTable + `"` + query := `TRUNCATE TABLE ` + ss.getMigrationTable() if _, err := tx.Exec(query); err != nil { if errRollback := tx.Rollback(); errRollback != nil { err = multierror.Append(err, errRollback) @@ -279,7 +279,7 @@ func (ss *SQLServer) SetVersion(version int, dirty bool) error { if dirty { dirtyBit = 1 } - query = `INSERT INTO "` + ss.config.MigrationsTable + `" (version, dirty) VALUES (@p1, @p2)` + query = `INSERT INTO ` + ss.getMigrationTable() + ` (version, dirty) VALUES (@p1, @p2)` if _, err := tx.Exec(query, version, dirtyBit); err != nil { if errRollback := tx.Rollback(); errRollback != nil { err = multierror.Append(err, errRollback) @@ -297,7 +297,7 @@ func (ss *SQLServer) SetVersion(version int, dirty bool) error { // Version of the current database state func (ss *SQLServer) Version() (version int, dirty bool, err error) { - query := `SELECT TOP 1 version, dirty FROM "` + ss.config.MigrationsTable + `"` + query := `SELECT TOP 1 version, dirty FROM ` + ss.getMigrationTable() err = ss.conn.QueryRowContext(context.Background(), query).Scan(&version, &dirty) switch { case err == sql.ErrNoRows: @@ -365,10 +365,10 @@ func (ss *SQLServer) ensureVersionTable() (err error) { query := `IF NOT EXISTS (SELECT * FROM sysobjects - WHERE id = object_id(N'[dbo].[` + ss.config.MigrationsTable + `]') + WHERE id = object_id(N'` + ss.getMigrationTable() + `') AND OBJECTPROPERTY(id, N'IsUserTable') = 1 ) - CREATE TABLE ` + ss.config.MigrationsTable + ` ( version BIGINT PRIMARY KEY NOT NULL, dirty BIT NOT NULL );` + CREATE TABLE ` + ss.getMigrationTable() + ` ( version BIGINT PRIMARY KEY NOT NULL, dirty BIT NOT NULL );` if _, err = ss.conn.ExecContext(context.Background(), query); err != nil { return &database.Error{OrigErr: err, Query: []byte(query)} @@ -377,6 +377,10 @@ func (ss *SQLServer) ensureVersionTable() (err error) { return nil } +func (ss *SQLServer) getMigrationTable() string { + return fmt.Sprintf("[%s].[%s]", ss.config.SchemaName, ss.config.MigrationsTable) +} + func getMSITokenProvider(resource string) (func() (string, error), error) { msi, err := adal.NewServicePrincipalTokenFromManagedIdentity(resource, nil) if err != nil { diff --git a/database/sqlserver/sqlserver_test.go b/database/sqlserver/sqlserver_test.go index afe7fd253..e7af5d7f9 100644 --- a/database/sqlserver/sqlserver_test.go +++ b/database/sqlserver/sqlserver_test.go @@ -96,6 +96,26 @@ func SkipIfUnsupportedArch(t *testing.T, c dktest.ContainerInfo) { } func Test(t *testing.T) { + t.Run("test", test) + t.Run("testMigrate", testMigrate) + t.Run("testMultiStatement", testMultiStatement) + t.Run("testErrorParsing", testErrorParsing) + t.Run("testLockWorks", testLockWorks) + t.Run("testMsiTrue", testMsiTrue) + t.Run("testOpenWithPasswordAndMSI", testOpenWithPasswordAndMSI) + t.Run("testMsiFalse", testMsiFalse) + + t.Cleanup(func() { + for _, spec := range specs { + t.Log("Cleaning up ", spec.ImageName) + if err := spec.Cleanup(); err != nil { + t.Error("Error removing ", spec.ImageName, "error:", err) + } + } + }) +} + +func test(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { SkipIfUnsupportedArch(t, c) ip, port, err := c.Port(defaultPort) @@ -120,7 +140,7 @@ func Test(t *testing.T) { }) } -func TestMigrate(t *testing.T) { +func testMigrate(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { SkipIfUnsupportedArch(t, c) ip, port, err := c.Port(defaultPort) @@ -149,7 +169,7 @@ func TestMigrate(t *testing.T) { }) } -func TestMultiStatement(t *testing.T) { +func testMultiStatement(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { SkipIfUnsupportedArch(t, c) ip, port, err := c.Port(defaultPort) @@ -183,7 +203,7 @@ func TestMultiStatement(t *testing.T) { }) } -func TestErrorParsing(t *testing.T) { +func testErrorParsing(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { SkipIfUnsupportedArch(t, c) ip, port, err := c.Port(defaultPort) @@ -215,7 +235,7 @@ func TestErrorParsing(t *testing.T) { }) } -func TestLockWorks(t *testing.T) { +func testLockWorks(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { SkipIfUnsupportedArch(t, c) ip, port, err := c.Port(defaultPort) @@ -254,7 +274,7 @@ func TestLockWorks(t *testing.T) { }) } -func TestMsiTrue(t *testing.T) { +func testMsiTrue(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { SkipIfUnsupportedArch(t, c) ip, port, err := c.Port(defaultPort) @@ -271,7 +291,7 @@ func TestMsiTrue(t *testing.T) { }) } -func TestOpenWithPasswordAndMSI(t *testing.T) { +func testOpenWithPasswordAndMSI(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { SkipIfUnsupportedArch(t, c) ip, port, err := c.Port(defaultPort) @@ -303,7 +323,7 @@ func TestOpenWithPasswordAndMSI(t *testing.T) { }) } -func TestMsiFalse(t *testing.T) { +func testMsiFalse(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { SkipIfUnsupportedArch(t, c) ip, port, err := c.Port(defaultPort) diff --git a/database/yugabytedb/yugabytedb_test.go b/database/yugabytedb/yugabytedb_test.go index dc9103ece..05fb14fa7 100644 --- a/database/yugabytedb/yugabytedb_test.go +++ b/database/yugabytedb/yugabytedb_test.go @@ -33,8 +33,8 @@ var ( } // Released versions: https://docs.yugabyte.com/preview/releases/release-notes/ specs = []dktesting.ContainerSpec{ - {ImageName: "yugabytedb/yugabyte:2.14.10.4-b1", Options: opts}, - {ImageName: "yugabytedb/yugabyte:2.20.0.2-b1", Options: opts}, + {ImageName: "yugabytedb/yugabyte:2.14.15.0-b57", Options: opts}, + {ImageName: "yugabytedb/yugabyte:2.20.2.1-b3", Options: opts}, } ) @@ -91,6 +91,22 @@ func getConnectionString(ip, port string, options ...string) string { } func Test(t *testing.T) { + t.Run("test", test) + t.Run("testMigrate", testMigrate) + t.Run("testMultiStatement", testMultiStatement) + t.Run("testFilterCustomQuery", testFilterCustomQuery) + + t.Cleanup(func() { + for _, spec := range specs { + t.Log("Cleaning up ", spec.ImageName) + if err := spec.Cleanup(); err != nil { + t.Error("Error removing ", spec.ImageName, "error:", err) + } + } + }) +} + +func test(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, ci dktest.ContainerInfo) { createDB(t, ci) @@ -109,7 +125,7 @@ func Test(t *testing.T) { }) } -func TestMigrate(t *testing.T) { +func testMigrate(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, ci dktest.ContainerInfo) { createDB(t, ci) @@ -133,7 +149,7 @@ func TestMigrate(t *testing.T) { }) } -func TestMultiStatement(t *testing.T) { +func testMultiStatement(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, ci dktest.ContainerInfo) { createDB(t, ci) @@ -163,7 +179,7 @@ func TestMultiStatement(t *testing.T) { }) } -func TestFilterCustomQuery(t *testing.T) { +func testFilterCustomQuery(t *testing.T) { dktesting.ParallelTest(t, specs, func(t *testing.T, ci dktest.ContainerInfo) { createDB(t, ci) diff --git a/dktesting/dktesting.go b/dktesting/dktesting.go index 342af2fdc..474bcc850 100644 --- a/dktesting/dktesting.go +++ b/dktesting/dktesting.go @@ -1,11 +1,15 @@ package dktesting import ( + "context" + "fmt" "testing" ) import ( "github.com/dhui/dktest" + "github.com/docker/docker/api/types" + "github.com/docker/docker/client" ) // ContainerSpec holds Docker testing setup specifications @@ -14,6 +18,30 @@ type ContainerSpec struct { Options dktest.Options } +// Cleanup cleanups the ContainerSpec after a test run by removing the ContainerSpec's image +func (s *ContainerSpec) Cleanup() (retErr error) { + // copied from dktest.RunContext() + dc, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("1.41")) + if err != nil { + return err + } + defer func() { + if err := dc.Close(); err != nil && retErr == nil { + retErr = fmt.Errorf("error closing Docker client: %w", err) + } + }() + cleanupTimeout := s.Options.CleanupTimeout + if cleanupTimeout <= 0 { + cleanupTimeout = dktest.DefaultCleanupTimeout + } + ctx, timeoutCancelFunc := context.WithTimeout(context.Background(), cleanupTimeout) + defer timeoutCancelFunc() + if _, err := dc.ImageRemove(ctx, s.ImageName, types.ImageRemoveOptions{Force: true, PruneChildren: true}); err != nil { + return err + } + return nil +} + // ParallelTest runs Docker tests in parallel func ParallelTest(t *testing.T, specs []ContainerSpec, testFunc func(*testing.T, dktest.ContainerInfo)) { diff --git a/go.mod b/go.mod index 282aec3e5..c7efd4c88 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,8 @@ require ( github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.33 // indirect github.com/cenkalti/backoff/v4 v4.1.2 github.com/cockroachdb/cockroach-go/v2 v2.1.1 - github.com/dhui/dktest v0.4.0 - github.com/docker/docker v24.0.7+incompatible + github.com/dhui/dktest v0.4.1 + github.com/docker/docker v24.0.9+incompatible github.com/docker/go-connections v0.4.0 github.com/fsouza/fake-gcs-server v1.17.0 github.com/go-sql-driver/mysql v1.5.0 @@ -25,15 +25,15 @@ require ( github.com/google/go-github/v39 v39.2.0 github.com/hashicorp/go-multierror v1.1.1 github.com/infobloxopen/hotload v0.0.0-20210618153036-1535a93a8521 - github.com/jackc/pgconn v1.13.0 - github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451 - github.com/jackc/pgx/v4 v4.17.2 - github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect - github.com/klauspost/compress v1.15.11 // indirect + github.com/jackc/pgconn v1.14.3 + github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa + github.com/jackc/pgx/v4 v4.18.2 + github.com/jackc/pgx/v5 v5.5.4 github.com/ktrysmt/go-bitbucket v0.6.4 github.com/lib/pq v1.10.9 github.com/markbates/pkger v0.15.1 - github.com/mattn/go-sqlite3 v1.14.14 + github.com/mattn/go-sqlite3 v1.14.22 + github.com/microsoft/go-mssqldb v1.6.0 github.com/mutecomm/go-sqlcipher/v4 v4.4.0 github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8 github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba @@ -47,9 +47,9 @@ require ( github.com/xanzy/go-gitlab v0.15.0 go.mongodb.org/mongo-driver v1.7.5 go.uber.org/atomic v1.7.0 - golang.org/x/net v0.18.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.14.0 - golang.org/x/sys v0.15.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/tools v0.10.0 google.golang.org/api v0.150.0 google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect @@ -57,6 +57,8 @@ require ( modernc.org/sqlite v1.18.1 ) +require github.com/jackc/puddle/v2 v2.2.1 // indirect + require ( cloud.google.com/go v0.110.10 // indirect cloud.google.com/go/compute v1.23.3 // indirect @@ -94,6 +96,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/go-units v0.5.0 // indirect + github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 // indirect github.com/envoyproxy/go-control-plane v0.11.1 // indirect github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect @@ -120,18 +123,15 @@ require ( github.com/jackc/chunkreader/v2 v2.0.1 // indirect github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.3.2 // indirect + github.com/jackc/pgproto3/v2 v2.3.3 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/pgtype v1.14.0 // indirect - github.com/jackc/pgx/v5 v5.5.0 - github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/k0kubun/pp v2.3.0+incompatible // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/magiconair/properties v1.8.0 // indirect github.com/mattn/go-colorable v0.1.6 // indirect github.com/mattn/go-isatty v0.0.16 // indirect - github.com/microsoft/go-mssqldb v1.6.0 github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/moby/term v0.5.0 // indirect github.com/morikuni/aec v1.0.0 // indirect @@ -154,11 +154,11 @@ require ( github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect gitlab.com/nyarla/go-crypt v0.0.0-20160106005555-d9a5dc2b789b // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/crypto v0.17.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect golang.org/x/mod v0.11.0 // indirect golang.org/x/sync v0.5.0 // indirect - golang.org/x/term v0.15.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect @@ -166,7 +166,7 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect google.golang.org/grpc v1.59.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect @@ -195,11 +195,12 @@ require ( github.com/apache/arrow/go/v10 v10.0.1 // indirect github.com/apache/thrift v0.16.0 // indirect github.com/danieljoos/wincred v1.1.2 // indirect - github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/goccy/go-json v0.9.11 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect + github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect github.com/klauspost/asmfmt v1.3.2 // indirect + github.com/klauspost/compress v1.15.11 // indirect github.com/klauspost/cpuid/v2 v2.0.9 // indirect github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect diff --git a/go.sum b/go.sum index f5fcc719d..37a5d545b 100644 --- a/go.sum +++ b/go.sum @@ -168,13 +168,13 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dhui/dktest v0.4.0 h1:z05UmuXZHO/bgj/ds2bGMBu8FI4WA+Ag/m3ghL+om7M= -github.com/dhui/dktest v0.4.0/go.mod h1:v/Dbz1LgCBOi2Uki2nUqLBGa83hWBGFMu5MrgMDCc78= +github.com/dhui/dktest v0.4.1 h1:/w+IWuDXVymg3IrRJCHHOkMK10m9aNVMOyD0X12YVTg= +github.com/dhui/dktest v0.4.1/go.mod h1:DdOqcUpL7vgyP4GlF3X3w7HbSlz8cEQzwewPveYEQbA= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM= -github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0= +github.com/docker/docker v24.0.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= @@ -182,8 +182,8 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= -github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= +github.com/dvsekhvalnov/jose2go v1.6.0 h1:Y9gnSnP4qEI0+/uQkHvFXeD2PLPJeXEL+ySMEA2EjTY= +github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 h1:aaQcKT9WumO6JEJcRyTqFVq4XUZiUcKR2/GI31TOcz8= github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -349,10 +349,10 @@ github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpT github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= -github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= -github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451 h1:WAvSpGf7MsFuzAtK4Vk7R4EVe+liW4x83r4oWu0WHKw= -github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds= +github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w= +github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM= +github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa h1:s+4MhCQ6YrzisK6hFJUX53drDT4UsSW3DEhKn0ifuHw= +github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -369,9 +369,8 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1: github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.3.2 h1:7eY55bdBeCz1F2fTzSz69QC+pG46jYq9/jtSPiJ5nn0= -github.com/jackc/pgproto3/v2 v2.3.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag= +github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= @@ -384,7 +383,6 @@ github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkAL github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ= github.com/jackc/pgtype v1.6.2/go.mod h1:JCULISAZBFGrHaOXIIFiyfzW5VY0GRitRr8NeJsrdig= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw= github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= @@ -395,16 +393,15 @@ github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6 github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg= github.com/jackc/pgx/v4 v4.10.1/go.mod h1:QlrWebbs3kqEZPHCTGyxecvzG6tvIsYu+A5b1raylkA= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E= -github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw= -github.com/jackc/pgx/v5 v5.5.0 h1:NxstgwndsTRy7eq9/kqYc/BZh5w2hHJV86wjvO+1xPw= -github.com/jackc/pgx/v5 v5.5.0/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= +github.com/jackc/pgx/v4 v4.18.2 h1:xVpYkNR5pk5bMCZGfClbO962UIqVABcAGt7ha1s/FeU= +github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= +github.com/jackc/pgx/v5 v5.5.4 h1:Xp2aQS8uXButQdnCMWNmvx6UysWQQC+u1EoizjguY+8= +github.com/jackc/pgx/v5 v5.5.4/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= @@ -480,8 +477,8 @@ github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peK github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.14 h1:qZgc/Rwetq+MtyE18WhzjokPD93dNqLGNT3QJuLvBGw= -github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microsoft/go-mssqldb v1.6.0 h1:mM3gYdVwEPFrlg/Dvr2DNVEgYFG7L42l+dGc67NNNpc= github.com/microsoft/go-mssqldb v1.6.0/go.mod h1:00mDtPbeQCRGC1HwOOR5K/gr30P1NcEG0vx6Kbv2aJU= @@ -672,10 +669,9 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -732,14 +728,13 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= -golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -804,16 +799,16 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= -golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -939,8 +934,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/cli/main.go b/internal/cli/main.go index 5167a09a0..ece7eff0b 100644 --- a/internal/cli/main.go +++ b/internal/cli/main.go @@ -323,7 +323,7 @@ Database drivers: `+strings.Join(database.List(), ", ")+"\n", createUsage, gotoU if needsConfirm { log.Println("Are you sure you want to apply all down migrations? [y/N]") var response string - fmt.Scanln(&response) + _, _ = fmt.Scanln(&response) response = strings.ToLower(strings.TrimSpace(response)) if response == "y" { @@ -354,7 +354,7 @@ Database drivers: `+strings.Join(database.List(), ", ")+"\n", createUsage, gotoU if !*forceDrop { log.Println("Are you sure you want to drop the entire database schema? [y/N]") var response string - fmt.Scanln(&response) + _, _ = fmt.Scanln(&response) response = strings.ToLower(strings.TrimSpace(response)) if response == "y" { diff --git a/migrate.go b/migrate.go index a57dceb5d..7763782a0 100644 --- a/migrate.go +++ b/migrate.go @@ -89,25 +89,25 @@ func New(sourceURL, databaseURL string) (*Migrate, error) { sourceName, err := iurl.SchemeFromURL(sourceURL) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to parse scheme from source URL: %w", err) } m.sourceName = sourceName databaseName, err := iurl.SchemeFromURL(databaseURL) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to parse scheme from database URL: %w", err) } m.databaseName = databaseName sourceDrv, err := source.Open(sourceURL) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to open source, %q: %w", sourceURL, err) } m.sourceDrv = sourceDrv databaseDrv, err := database.Open(databaseURL) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to open database, %q: %w", databaseURL, err) } m.databaseDrv = databaseDrv @@ -131,7 +131,7 @@ func NewWithDatabaseInstance(sourceURL string, databaseName string, databaseInst sourceDrv, err := source.Open(sourceURL) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to open source, %q: %w", sourceURL, err) } m.sourceDrv = sourceDrv @@ -149,7 +149,7 @@ func NewWithSourceInstance(sourceName string, sourceInstance source.Driver, data databaseName, err := iurl.SchemeFromURL(databaseURL) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to parse scheme from database URL: %w", err) } m.databaseName = databaseName @@ -157,7 +157,7 @@ func NewWithSourceInstance(sourceName string, sourceInstance source.Driver, data databaseDrv, err := database.Open(databaseURL) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to open database, %q: %w", databaseURL, err) } m.databaseDrv = databaseDrv