Commit Graph
82 Commits
Author SHA1 Message Date
e40cf943ca ci: update golangci-lint to v2 (#1341)
* ci: update golangci-lint to v2

update method:
```
golangci-lint migrate
golangci-lint run --fix
```

and fix the last ones manually

* Apply suggestion from @Copilot

* fix tests

---------

Co-authored-by: Hanzo Dev <[email protected]>
2025-12-14 15:14:46 -08:00
leonklingeleandGitHub 426470006b chore: remove dependency on "hashicorp/go-multierror" (#1322)
* feat: remove dependency on "hashicorp/go-multierror"

It seems the project has been unmainted for quite some time already,
see for example https://github.com/hashicorp/go-multierror/issues/97
and https://github.com/hashicorp/go-multierror/issues/98.
This also removes an uneccessary dependency which slims down the go.mod.

Go as of version 1.20 supports appending errors by specifying
multiple "%w" formatters in the "fmt.Errorf"[^0] function.

[^0]: https://pkg.go.dev/fmt#Errorf

* feat: use errors.Join to combine multiple errors

As an update to the previous commit 59f084ea3be2e7ec9d912c1a311402b1e4c40df6,
use "errors.Join"[^0] instead of multiple "%w" formatters for "fmt.Errorf".

[^0]: https://pkg.go.dev/errors#Join

* chore: bring back unused util.go file as removing it is a breaking change
2025-11-29 11:37:42 -08:00
Roman SharkovandGitHub 34fa67d9f6 Merge pull request #1303 from romshark/master
refactor: Remove go.uber.org/atomic in favor of std sync/atomic
2025-08-20 16:35:25 -07:00
Oleksandr Redko fca627ee8e Remove redundant build tags 2025-04-17 23:57:28 +03:00
Dale HuiandGitHub 242d80d406 Fix CI (#1222)
* Run go mod tidy

* Fix Github linting action

Changes:
* checkout before setting up go
* pin golangci-lint version

* Update supported db versions

* Use start-single-node instead of start for cockroachdb
2025-01-26 15:46:11 -08:00
Jochen Schalanda e57f9d578f test(postgres): run tests with PostgreSQL 16 2024-09-07 21:47:48 +02:00
Dale Hui bcc589c6d9 Cleanup postgres images after tests run 2024-04-15 00:17:36 -07:00
Toby ScottandGitHub 4f2aa4058a Add syntax highlighting to Postgres example 2023-11-04 12:24:32 +11:00
Vladimir Galunshchikov 0f106462cb fix: postgresql search_path can be empty (#696) 2023-04-06 23:48:03 +02:00
Abhinav Nair baec8ed6b6 Replace deprecated ioutil pkg with os & io
As of Go 1.16, the same functionality is now provided by package io or
package os, and those implementations should be preferred in new code.

So replacing all usage of ioutil pkg with io & os.
2022-06-26 16:57:29 +08:00
Andreas Kluth e08ebbab82 Add WithConnection to Postgres similar to MySQL. 2021-11-29 15:50:04 +01:00
Dale Hui 1294fa4cfa Update build constraints
Issue caught by linter

https://pkg.go.dev/go/build#hdr-Build_Constraints
https://pkg.go.dev/cmd/go#hdr-Build_constraints
https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md
2021-09-10 21:04:11 -07:00
bef0635743 used uber atomic bool instead standard in lock/unlock db (#580)
* used uber atomic bool instead standard in lock/unlock db

* fixing local lock optimization implementation

* fixing mysql local lock optimization implementation

* fixing cockroachdb local lock optimization implementation

* CAS wrapper to automatically restore

* added test for cas with restore

* added atomic lock to sqlite & mongo

* added atomic lock to sqlite & mongo

* fix/refactor test cas restore function

* disable lock for mongo

* mongo local lock before acquiring the db lock

Co-authored-by: a.prinkov <[email protected]>
2021-06-23 14:40:50 -07:00
Stéphane Klein b10f5e9868 postgres,pgx: fix SchemaName parameter is ignored ##547 2021-04-25 07:34:19 +02:00
Stéphane KleinandGitHub 267936eff9 Postgres - add x-migrations-table-quoted url query option (#95) (#533)
* Postgres and pgx - Add x-migrations-table-quoted url query option to postgres and pgx drivers (#95)

By default, gomigrate quote migrations table name, if `x-migrations-table-quoted` is enabled, then you must to quote migrations table name manually, for instance `"gomigrate"."schema_migrations"`

* Work In Progress
2021-04-19 14:57:50 -07:00
testtest959andGitHub 06029ba265 Postgres: Add a check to determine if table already exists to elide CREATE query (#526)
* Squash commits

* Format

* Minor refactoring

* Address PR feedback; Add mustRun

* Fix a test assert
2021-03-18 21:03:57 -07:00
Dale Hui 15f7a994b2 Use strconv.ParseBool() to parse the x-multi-statement option in the postgres driver 2021-02-03 22:59:24 -08:00
Anatoly Rugalev f19abe070c Addressed review comments 2021-02-02 11:24:33 +01:00
Anatoly Rugalev 32963ee38f Support multi-statement execution for PostgreSQL 2021-01-18 12:16:37 +03:00
Maarten BezemerandGitHub dc79a58cfe postgres - Force MigrationsTable in 'public' schema (#414)
* Force MigrationsTable on public schema

* Revert "Force MigrationsTable on public schema"

This reverts commit e5b25e8858ed42d19d420cb8bd16795c060994d2.

* Add example to fix search_path issue

* Use POSTGRESQL_URL in example and fix typo

* Make example simpler by using the `search_path` query parameter of the DB URL
2020-10-15 20:21:00 -07:00
Igor Zibarev 2a7a3a7c7a Check iterator error on Drop where applicable 2020-10-10 23:53:20 +03:00
Dale Hui bdeb9a83fe Correctly mark migrations as dirty when the first down migration fails
Fixes: https://github.com/golang-migrate/migrate/issues/330

Other changes:
  - Cleanup code by using the database.NilVersion constant instead of the magic number -1
2020-04-06 00:07:15 -07:00
Dale Hui 0c12284328 POSTGRES_PASSWORD is now required when using postgres via docker
See: https://github.com/docker-library/postgres/issues/681
2020-02-16 01:37:09 -08:00
Dale Hui 4447ce64dc Drop support for postgres 9.4 and add support for postgres 12
https://www.postgresql.org/about/news/2011/
https://www.postgresql.org/about/news/1976/
2020-02-16 00:38:23 -08:00
Bret ComnesandGitHub 3bfb55bbcc Fix URL in tutorial
This link needed to be updated.
2020-01-31 14:13:30 -07:00
a7f74d4466 add statement timeout query param for postgres (#327)
* add statement timeout query param for postgres

* Update database/postgres/postgres.go

Co-Authored-By: Roopak Venkatakrishnan <[email protected]>

* add enable flag

* remove deafult catch errors

* reformat

* only use background context for 0 timeout

* refactor

* refactor

Co-authored-by: Pranay Suresh <[email protected]>
Co-authored-by: Roopak Venkatakrishnan <[email protected]>
2020-01-21 11:22:41 -08:00
Dale Hui fc9600340b Remove unnecessary byte slice arg from TestMigrate() in database/testing 2020-01-03 00:15:52 -08:00
Marcin K 2fea7dce94 Prevent shell interpretation in the exported variables 2020-01-02 20:17:56 +01:00
Dale Hui a25d1fcaa9 Actually use schema and db names specified in postgres db config
Addresses: https://github.com/golang-migrate/migrate/issues/262
2019-10-13 23:24:10 -07:00
Calvin Tuong d1ec7ba5aa Update postgres driver Lock comment to reflect actual behavior 2019-09-24 13:57:01 -07:00
Marcin K 1461837691 Put tutorial specific info into a separate file 2019-08-11 22:06:04 +02:00
Kirill MuratovandDale Hui 8afa5fa221 Enabled maligned, staticcheck and errcheck linters (#206)
* Enabled maligned check

* Enabled staticcheck

* Fixes for golint

* Enabled errcheck linter

* Added fixes for error check

* Added errcheck for tests

* Fixed test

* Increased golangci-lint deadline for travis

* Increased golangci-lint deadline for travis

* Decreased golangci-lint deadline for travis

* Revert for backward compatibility

* Using log.Println() instead of fmt.Println()

* Handling os.RemoveAll() errors

* Using t.Error(error) instead of t.Errorf("%v", err)

* Using t.Fatal(error) instead of t.Fatalf("%v", err)

* Using fmt.Sprint(sum) instead of t.Srintf("%v", sum)

* Refactoring

* Revert for backward compatibility

* Revert

* go mod tidy

* Added error logging

* Added error logging

* Added error handling

* Added error handling

* Added error logging

* Fix error logging

* Added error handling

* Fix

* Added logging for migr.Buffer()

* Fixes

* Firebird test disabled

* Fixed nolint comment

* Updated firebird docker image version

* Disabled test for firebird 2.5

* Fixed // nolint
2019-04-26 15:47:16 -07:00
Kirill MuratovandDale Hui fea2fd1741 Added Firebird support (#191)
* Added Firebird support

* Fixed typo

* Refactoring

* Schema migrations table name don't have to be upper case

* Fixed readme

* Added Firebird 2.5 support

* Removed SchemaName

* Refactoring
2019-03-21 01:51:49 -07:00
Lukas JoergensenandDale Hui 1cc735c192 postgres: Move lock out of ensureVersionTable, for consistency with other SQL operations (#173)
* Consistently lock in ensureVersionTable and do not call ensureVersionTable from Drop across all database implementations

* Add test for dropping postgres databases

* Fix failing database tests

* Fix CockroachDb test, lock table should be created before versionTable

* Add Initialize() to Driver interface, and add integration tests for Drop() between database implementations and migrate

* Remove Initialize, document breaking behaviour of Drop

* Revert introduction of Initialize method

* Removed Initialize in Stub as well

* Remove call to non-existent Initialize and make sure to close re-initialized database connections

* Revert changes to TestDrop in database/testing

* Split Test and TestMigrate into different test entrypoints

* Remove unused import in migrate_testing

* Remove erroneous code to fix tests

* Add stub source imports to database tests

* Add Stub source to migrate tests

* Use example migrations for tests

* Add file driver to database tests

* Align database directory layout

* Add file source driver to Cassandra

* Review changes

* Minor syntactic change for cleaner diff
2019-02-26 15:56:57 -08:00
Jesse Szwedko 6c1f149746 Replace " quoting with pq.QuoteIdentifier for postgres driver 2019-02-18 11:44:38 +01:00
Jesse Szwedko 00d8f2956a Quote postgres table identifiers when DROPing
Handles table identifiers that are invalid without quotes (such as
uppercase letters).
2019-02-18 11:29:10 +01:00
Tomás Senart 4028eca4f5 fixup! More explicit conditionals 2019-01-15 11:28:49 +01:00
Tomás Senart 317883e4db postgres: Revert back to use CREATE IF NOT EXISTS 2019-01-15 11:28:49 +01:00
Tomás Senart 12e427b0ee postgres: Use multierror.Error in ensureVersionTable 2019-01-15 11:28:49 +01:00
Tomás Senart ff6cbc9917 postgres: Be explicit about max idle and open conns 2019-01-15 11:28:48 +01:00
Tomás Senart 90ce263ff7 postgres: Query table existance in ensureVersionTable
This commit reverts back to querying the existance of the table instead
of using CREATE IF NOT EXISTS because we want to support versions of
Postgres older than 9.1 which is when this feature was introduced.
2019-01-15 11:28:48 +01:00
Tomás Senart 3ca1d6cd11 postgres: Add comment about connection pool in TestWithInstance_Concurrent 2019-01-15 11:28:48 +01:00
Tomás Senart ebb0da0f4c postgres: Preserve Unlock error when outer err isn't nil 2019-01-15 11:28:48 +01:00
Tomás Senart 18370420c7 postgres: Use sync.WaitGroup in TestWithInstance_Concurrent 2019-01-15 11:28:48 +01:00
Tomás Senart b1407e80cb postgres: Make ensureVersionTable atomic
Fixes https://github.com/golang-migrate/migrate/issues/55
2019-01-15 11:28:48 +01:00
Tomás Senart cb49a9f197 fixup! Pass config to WithInstance 2019-01-15 11:28:48 +01:00
Tomás Senart cff46c00d8 postgres: TestWithInstance_Concurrent 2019-01-15 11:28:47 +01:00
Dale Hui 932ef4bbd5 Update supported DB versions 2019-01-12 16:13:26 -08:00
Dale Hui 04b5c714cc Update dktest from v0.2.0 to v0.3.0
- Update ReadyFuncs accordingly
2019-01-08 22:39:26 -08:00
Dale Hui c2ec17eddf Use dktest to run docker tests
- Leaving migrate/testing in case there are unknown consumers
    - Add migrate/dktesting package
    - Update tests to use migrate/dktesting instead of migrate/testing
2019-01-08 05:11:07 -08:00