Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
90273fe
clickhouse: Quote db name in ensureVersionTable
luca-nardelli Nov 29, 2022
9fe7383
Quote in drop as well
luca-nardelli Nov 30, 2022
839421e
Leverage quoteIdentifier from pgx
luca-nardelli Nov 30, 2022
50112e7
Add to clickhouse README.md database creation
volum-nova Jan 24, 2023
90a3ac4
Remove cluster adaptation for tables to pass tests
volum-nova Jan 24, 2023
64755d0
Update README.md
volum-nova Jan 24, 2023
3b02b18
Correct a spelling mistake
volum-nova Mar 19, 2023
92dec35
Move supported go version to standard place
SuperSandro2000 Jun 1, 2023
7a72550
add tests for scylladb. add scylladb to docs
mkorolyov Jun 21, 2023
bad30b5
Mention migradaptor
dhui Jul 3, 2023
208ac53
Update spanner to fix security issue
dhui Jul 6, 2023
856ea12
Merge pull request #953 from dhui/update_spanner
dhui Jul 6, 2023
45d23ed
Merge branch 'master' into scylladb_support
mkorolyov Jul 11, 2023
f8afa5a
small changes to retry failed by timeout CI
mkorolyov Jul 17, 2023
876a13d
Update aws-sdk-go to adress vulerabilitiy
Kenai Jul 18, 2023
f2e0b33
Update lib/pq to fix cert permissions issues
jorng Jul 20, 2023
129922a
Added support for pgx locking table
fortnox-andreas Sep 20, 2023
bead4a9
Added documentation and test for lock strategy
tsfcode Sep 20, 2023
12968a7
Add syntax highlighting to Postgres example
tbysctt Nov 4, 2023
72957b6
Updated version of spanner to support sequences and generate uuid
jsabbatini-upguard Nov 14, 2023
ee8a8e5
fix: typo
testwill Nov 27, 2023
5163ac7
feature: add rqlite support
swensone Nov 5, 2023
cf03803
Add rqlite 8.0.0 to tested database versions
swensone Dec 6, 2023
669437c
update rqlite 8 container version to 8.0.6
swensone Dec 14, 2023
7eac919
Merge pull request #1006 from testwill/typo
dhui Dec 19, 2023
4078ef8
New release prep
dhui Dec 19, 2023
b567287
Update from alpine 3.18 to 3.19
dhui Dec 19, 2023
5ded96d
Bump golang.org/x/crypto from 0.14.0 to 0.17.0
dependabot[bot] Dec 19, 2023
7d03609
add 8.11 and 8.12 versions and remove debug logging
swensone Dec 19, 2023
bfedabb
Merge remote-tracking branch 'upstream/master'
swensone Dec 19, 2023
834fa39
Merge pull request #1014 from golang-migrate/dependabot/go_modules/go…
dhui Dec 20, 2023
f375aeb
Merge pull request #1007 from swensone/master
dhui Dec 20, 2023
c3ebd52
Bump google.golang.org/grpc from 1.55.0 to 1.56.3
dependabot[bot] Dec 20, 2023
b39ee92
Merge pull request #999 from tobyscott25/patch-1
dhui Dec 20, 2023
47a2661
Merge pull request #1015 from golang-migrate/dependabot/go_modules/go…
dhui Dec 20, 2023
fb22436
Merge remote-tracking branch 'origin/master' into upgrade-spanner
dhui Dec 20, 2023
5026488
Clean up require directive grouping
dhui Dec 20, 2023
90c5015
Merge pull request #959 from jorng/libpq-update
dhui Dec 20, 2023
76efa72
Merge branch 'master' into master
dhui Dec 20, 2023
1d1cd48
Merge branch 'master' into scylladb_support
dhui Dec 20, 2023
0695426
Merge pull request #929 from SuperSandro2000/patch-1
dhui Dec 20, 2023
2063684
Merge branch 'master' into master
dhui Dec 20, 2023
0ba6fc3
Merge pull request #1002 from jsabbatini-upguard/upgrade-spanner
dhui Dec 20, 2023
a94396c
Merge pull request #857 from luca-nardelli/master
dhui Dec 20, 2023
eb64ffa
Merge pull request #947 from mkorolyov/scylladb_support
dhui Dec 20, 2023
691f687
Reformat ScyllaDB/Cassandra docs
dhui Dec 20, 2023
e8edcdc
Merge branch 'master' into master
dhui Dec 20, 2023
ab24e76
Merge branch 'master' into clickhouse_create_database_migrations
dhui Dec 20, 2023
091ad5d
Quote locktable from config in queries
tsfcode Dec 20, 2023
9c551d4
Merge pull request #875 from no-name16/clickhouse_create_database_mig…
dhui Dec 20, 2023
c7c5011
Merge pull request #956 from Kenai/master
dhui Dec 20, 2023
f2c4b52
Update aws-sdk-go from v1.44.301 to v1.49.6
dhui Dec 20, 2023
cd17c5a
Drop support for Go 1.19 and add support for Go 1.21
dhui Dec 20, 2023
d63a5c2
Only test against YugabyteDB LTS releases
dhui Dec 20, 2023
5aa4670
Fix GoReleaser deprecations
dhui Dec 20, 2023
0815e2d
Merge pull request #992 from fortnox-andreas/master
dhui Dec 20, 2023
8147693
[sqlserver] Ensure version table in provided schema
alex-kuck Oct 26, 2022
0350a00
[sqlserver] Always access version table with explicit schema
alex-kuck Oct 26, 2022
516f038
Merge pull request #840 from alex-kuck/fix/839/sqlserver_version_table
dhui Dec 31, 2023
a860f0c
Bump github.com/dvsekhvalnov/jose2go from 1.5.0 to 1.6.0
dependabot[bot] Dec 31, 2023
0d41589
Merge pull request #1022 from golang-migrate/dependabot/go_modules/gi…
dhui Jan 2, 2024
94b8fa5
rqlite is spelled with all lowercase
otoolep Jan 5, 2024
a5dc5d1
Merge pull request #1025 from otoolep/patch-1
dhui Jan 11, 2024
7f85f9c
chore: fix some typos
occupyhabit Mar 23, 2024
ff8a961
Update yugabyte test images
dhui Mar 25, 2024
87ba13c
Merge pull request #1061 from occupyhabit/master
dhui Mar 25, 2024
e913336
Drop support for Go 1.20 and add support for Go 1.22
dhui Mar 25, 2024
9d70a39
chore: fix some typos in comments
goodfirm Apr 10, 2024
4bc6777
Add dktesting.Cleanup() method
dhui Apr 15, 2024
2884a8e
Cleanup postgres images after tests run
dhui Apr 15, 2024
1b707a7
Cleanup cassandra images after tests run
dhui Apr 15, 2024
06614d9
Cleanup yugabytedb images after tests run
dhui Apr 15, 2024
49cac86
Cleanup mongodb images after tests run
dhui Apr 15, 2024
b1d02e2
Cleanup sqlserver images after tests run
dhui Apr 16, 2024
f4950c1
Fallback to dktest.DefaultCleanupTimeout if the dktest.Options doesn'…
dhui Apr 16, 2024
2c5df87
Merge pull request #1072 from dhui/dktesting-cleanup
dhui Apr 16, 2024
1a002d0
Set golangci-lint to 1.54.2 (latest is broken) (#1046)
rockdaboot Apr 16, 2024
d1df97b
Bump github.com/jackc/pgx/v4 from 4.18.1 to 4.18.2
dependabot[bot] Apr 16, 2024
2e0872f
Bump google.golang.org/protobuf from 1.31.0 to 1.33.0
dependabot[bot] Apr 16, 2024
128b650
Merge pull request #1050 from golang-migrate/dependabot/go_modules/gi…
dhui Apr 16, 2024
837776f
Merge pull request #1054 from golang-migrate/dependabot/go_modules/go…
dhui Apr 16, 2024
a78d1ab
Bump github.com/jackc/pgx/v5 from 5.3.1 to 5.5.4
dependabot[bot] Apr 16, 2024
c523775
Merge pull request #1055 from golang-migrate/dependabot/go_modules/gi…
dhui Apr 17, 2024
f100226
Update dktest from v0.4.0 to v0.4.1 to fix docker vulnerability
dhui Apr 17, 2024
0c456c4
Merge pull request #1068 from goodfirm/master
dhui Apr 17, 2024
e428ece
Make MySQL SetVersion compatible with sql_safe_update
maxmati Apr 10, 2024
859d92b
Bump golang.org/x/net from 0.21.0 to 0.23.0
dependabot[bot] Apr 19, 2024
45e4f1e
Merge pull request #1074 from golang-migrate/dependabot/go_modules/go…
dhui Apr 30, 2024
04b36eb
Merge pull request #1070 from certifaction/mysql-safe-update
dhui Apr 30, 2024
c81eaf7
Upgrade go-sqlite3 to v1.14.22
gjabell May 31, 2024
da72428
Update README.md
adityassharma-ss Jun 4, 2024
cabb2db
🧑‍💻 improve error message for invalid source, database, resolves: #1102
Shion1305 Jun 5, 2024
1735cb3
🚨 golangci-lint: disable interfacer linter
Shion1305 Jun 5, 2024
34594af
🚨 golangci-lint: fix for errcheck lint errors
Shion1305 Jun 5, 2024
b16220c
Merge pull request #1105 from Shion1305/shion/issue-1104
dhui Jun 10, 2024
1585b87
Merge pull request #1103 from Shion1305/shion/issue-1102
dhui Jun 10, 2024
2477f63
Merge pull request #1098 from gjabell/master
dhui Jun 10, 2024
41e389a
Support .deb package for Noble Numbat (24.04)
muzammilar Jul 17, 2024
899a244
Fix redshift tests
dhui Aug 30, 2024
e1a7e31
Use forked version of postgres 8 to avoid Docker image format version…
dhui Sep 6, 2024
f44379d
Merge pull request #1151 from dhui/fix-redshift-tests
dhui Sep 6, 2024
1b1c6f6
Use newer math/rand/v2
dhui Aug 26, 2024
897be38
chore: remove deprecated `rand.Seed()` in testing.docker (#1149)
joschi Sep 7, 2024
d28e549
Update dktest from v0.4.1 to v0.4.2
dhui Sep 7, 2024
ee93fd4
build: use Go 1.23 to build the project
joschi Aug 13, 2024
f4d986b
test(mysql): run tests with MySQL 8.0, 8.4, and 9.0
joschi Aug 7, 2024
0444ec8
test(postgres): run tests with PostgreSQL 16
joschi Aug 7, 2024
6ceb5a9
fix(tests): fix Docker imports
joschi Sep 7, 2024
e40e64c
Merge pull request #1133 from joschi/go-1.23
dhui Sep 8, 2024
65a3bd5
Merge pull request #1153 from joschi/fix-docker-imports
dhui Sep 8, 2024
7e8f6be
Merge pull request #1126 from joschi/tests-postgres-16
dhui Sep 8, 2024
ddd7fa6
Merge pull request #1127 from joschi/tests-mysql-9
dhui Sep 8, 2024
5b6f623
Bump google.golang.org/grpc from 1.64.0 to 1.64.1
dependabot[bot] Sep 8, 2024
1e02b42
Merge pull request #1119 from muzammilar/add-noble-numbat
dhui Sep 8, 2024
67c71f9
Merge pull request #1152 from golang-migrate/dependabot/go_modules/go…
dhui Sep 8, 2024
d5eb594
Merge pull request #1101 from adityassharma-ss/patch-1
dhui Sep 8, 2024
555501f
Update dktest from v0.4.2 to v0.4.3
dhui Sep 8, 2024
e22d012
Don't output sensitive information on error
Sep 12, 2024
c378583
Merge pull request #1162 from rselbach/rselbach/no-sensitive-info
dhui Sep 23, 2024
c5137c4
Update migrate -help output for the readme file
mathieu-pillar Oct 2, 2024
8b09191
fix: typo limited not limitted
Rambatino Nov 28, 2024
bc06922
Update dktest from v0.4.3 to v0.4.4
dhui Jan 26, 2025
12c619e
Fix CI (#1222)
dhui Jan 26, 2025
e5a152b
Drop support for Azure SQL Edge
dhui Jan 27, 2025
7651c8a
linter fixes
dhui Jan 27, 2025
e145cde
Bump github.com/golang-jwt/jwt/v4 from 4.4.2 to 4.5.1
dependabot[bot] Jan 27, 2025
d477553
Merge pull request #1195 from golang-migrate/dependabot/go_modules/gi…
dhui Jan 27, 2025
a868033
Update FAQ.md - typo
stensonb Feb 2, 2025
24a6476
Merge pull request #1225 from stensonb/patch-1
dhui Feb 20, 2025
36d17ba
tests: fix various tests (#1209)
joschi Feb 20, 2025
60d73be
refactor: replace github.com/pkg/errors with stdlib
hazzik Mar 10, 2025
a4d0a1b
Bump github.com/golang-jwt/jwt/v4 from 4.5.1 to 4.5.2
dependabot[bot] Mar 21, 2025
604248c
Merge pull request #1250 from golang-migrate/dependabot/go_modules/gi…
dhui Mar 23, 2025
146bfa0
Merge pull request #1241 from hazzik/refactor/pkg/errors
dhui Apr 16, 2025
e6d84f6
Drop support for Go 1.22 and add support for Go 1.24
dhui Apr 16, 2025
fccd197
Mention CLI install instructions in main README
dhui Apr 16, 2025
7269490
Update golangci-lint version used in GitHub Actions
dhui Apr 16, 2025
1af841d
Merge pull request #1260 from dhui/update_go
dhui Apr 16, 2025
f37ef79
Bump golang.org/x/crypto from 0.31.0 to 0.35.0
dependabot[bot] Apr 16, 2025
3c3ce91
Merge pull request #1258 from golang-migrate/dependabot/go_modules/go…
dhui Apr 17, 2025
5b97c92
Bump golang.org/x/net from 0.33.0 to 0.38.0
dependabot[bot] Apr 17, 2025
a3b7633
Merge pull request #1259 from golang-migrate/dependabot/go_modules/go…
dhui Apr 17, 2025
34c2b4a
Remove redundant build tags
alexandear Mar 11, 2025
329152e
Merge pull request #1196 from Rambatino/patch-1
dhui Apr 17, 2025
033835a
Update to dktest v0.4.5
dhui Apr 17, 2025
1049490
Merge pull request #1179 from lunfel/master
dhui Apr 17, 2025
9023d66
Merge pull request #1244 from alexandear-org/chore-redundant-build-tags
dhui Apr 17, 2025
6b9f24b
Fixed sqlserver not actually getting a lock if lock is already set
urbim Oct 11, 2024
2788339
Merge pull request #1186 from urbim/bugfix/sqlserverLockFix
dhui Apr 25, 2025
5300864
fix(docs): update Linux installation instructions for GPG key handling
sandhilt May 13, 2025
642a24d
Bump golang.org/x/oauth2 from 0.18.0 to 0.27.0
dependabot[bot] Jul 18, 2025
30690d7
Rename databaseName to databaseDriverName
iamonah Aug 3, 2025
5eee0c8
Merge pull request #1299 from golang-migrate/dependabot/go_modules/go…
dhui Aug 19, 2025
0a17402
Update dktest to v0.4.6 for docker vuln fix
dhui Aug 19, 2025
f3e6b5a
Replace usage of deprecated docker types
dhui Aug 19, 2025
682016f
Merge pull request #1277 from sandhilt/doc/change-apt-key-to-gpg
dhui Aug 19, 2025
7108d80
Merge pull request #1309 from dhui/dktest_v0.4.6
dhui Aug 19, 2025
8945e85
Merge pull request #1303 from romshark/master
romshark Aug 20, 2025
ed4bdd4
Ensure bufferWriter is always closed in Migration.Buffer and propagat…
ckantcs Aug 23, 2025
b4ec9bc
Add support for Go 1.25 and drop support for 1.23
dhui Aug 23, 2025
8b9c5f7
Merge pull request #1310 from dhui/update_go
dhui Aug 24, 2025
39ab04d
Update goreleaser Go version from 1.24.x to 1.25.x
dhui Nov 9, 2025
952d08e
fix linter issues
HaraldNordgren Oct 30, 2025
1ee8337
revert GenerateAdvisoryLockID
HaraldNordgren Nov 11, 2025
ce3cb72
Update docker image
matsoob Nov 13, 2025
3f583f0
Bump github.com/dvsekhvalnov/jose2go from 1.6.0 to 1.7.0
dependabot[bot] Nov 14, 2025
a51d0da
Merge pull request #1334 from golang-migrate/dependabot/go_modules/gi…
dhui Nov 19, 2025
70e6d6d
Merge pull request #1333 from matsoob/updateGoInBaseImage
dhui Nov 19, 2025
6dd86e0
Bump golang.org/x/crypto from 0.36.0 to 0.45.0
dependabot[bot] Nov 20, 2025
f939a89
Merge pull request #1335 from golang-migrate/dependabot/go_modules/go…
dhui Nov 27, 2025
43cc3b3
Merge pull request #1325 from HaraldNordgren/linter_issues
dhui Nov 27, 2025
a371c8e
Merge pull request #1304 from iamonah/fix/clarify-databaseName-meaning
dhui Nov 27, 2025
9f9df7c
chore: Update cloud.google.com/go/spanner version (#1330)
jferrl Nov 27, 2025
8d76259
Bump golang.org/x/crypto from 0.43.0 to 0.45.0
dependabot[bot] Nov 27, 2025
472ef2e
Merge pull request #1336 from golang-migrate/dependabot/go_modules/go…
dhui Nov 27, 2025
fed8fe9
Upgrade pgx v5 to latest version
achanda Oct 2, 2025
89e308c
chore: remove dependency on "hashicorp/go-multierror" (#1322)
leonklingele Nov 29, 2025
001b70a
ci: update golangci-lint to v2 (#1341)
PascalBourdier Dec 14, 2025
257fa84
Merge pull request #1320 from achanda/upgrade-pgxv5
dhui Dec 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20.x"
- uses: actions/checkout@v3
go-version: "1.25.x"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v9
with:
version: latest
version: v2.6.2

test:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.19.x", "1.20.x"]
go: ["1.24.x", "1.25.x"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

Expand Down Expand Up @@ -60,30 +60,30 @@ jobs:
# 3. When the workflow is triggered by a tag with `v` prefix
if: ${{ success() && github.repository == 'golang-migrate/migrate' && startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: "1.19.x"
go-version: "1.25.x"

- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: golangmigrate
password: ${{ secrets.DOCKERHUB_TOKEN }}

- run: echo "SOURCE=$(make echo-source)" >> $GITHUB_ENV
- run: echo "DATABASE=$(make echo-database)" >> $GITHUB_ENV

- uses: goreleaser/goreleaser-action@v2
- uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -97,6 +97,9 @@ jobs:
- run: package_cloud push golang-migrate/migrate/ubuntu/jammy dist/migrate.linux-amd64.deb
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- run: package_cloud push golang-migrate/migrate/ubuntu/noble dist/migrate.linux-amd64.deb
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- run: package_cloud push golang-migrate/migrate/debian/buster dist/migrate.linux-amd64.deb
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
Expand Down
47 changes: 29 additions & 18 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
version: "2"
linters:
enable:
#- golint
- interfacer
- unconvert
#- dupl
- goconst
- gofmt
- misspell
- unparam
- nakedret
- prealloc
#- gosec
linters-settings:
misspell:
locale: US
- revive
- unconvert
- unparam
settings:
misspell:
locale: US
revive:
rules:
- name: redundant-build-tag
exclusions:
generated: lax
rules:
- path: (.+)\.go$
text: G104
paths:
- third_party$
- builtin$
- examples$
issues:
max-same-issues: 0
max-issues-per-linter: 0
exclude-use-default: false
exclude:
# gosec: Duplicated errcheck checks
- G104
max-same-issues: 0
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ release:
prerelease: auto
source:
enabled: true
rlcp: true
format: zip
changelog:
skip: false
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20-alpine3.18 AS builder
FROM golang:1.25-alpine3.21 AS builder
ARG VERSION

RUN apk add --no-cache git gcc musl-dev make
Expand All @@ -15,7 +15,7 @@ COPY . ./

RUN make build-docker

FROM alpine:3.18
FROM alpine:3.21

RUN apk add --no-cache ca-certificates

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.github-actions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.18
FROM alpine:3.19

RUN apk add --no-cache ca-certificates

Expand Down
4 changes: 2 additions & 2 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
and whenever we want, not just once at the beginning of all tests.

#### Can I maintain my driver in my own repository?
Yes, technically thats possible. We want to encourage you to contribute your driver to this respository though.
Yes, technically thats possible. We want to encourage you to contribute your driver to this repository though.
The driver's functionality is dictated by migrate's interfaces. That means there should really
just be one driver for a database/ source. We want to prevent a future where several drivers doing the exact same thing,
just implemented a bit differently, co-exist somewhere on GitHub. If users have to do research first to find the
Expand All @@ -65,7 +65,7 @@
and then "force" the expected version.

#### What happens if two programs try and update the database at the same time?
Database-specific locking features are used by *some* database drivers to prevent multiple instances of migrate from running migrations at the same time
Database-specific locking features are used by *some* database drivers to prevent multiple instances of migrate from running migrations on
the same database at the same time. For example, the MySQL driver uses the `GET_LOCK` function, while the Postgres driver uses
the `pg_advisory_lock` function.

Expand Down
2 changes: 1 addition & 1 deletion GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ migrate -database YOUR_DATABASE_URL -path PATH_TO_YOUR_MIGRATIONS up

Just add the code to your app and you're ready to go!

Before commiting your migrations you should run your migrations up, down, and then up again to see if migrations are working properly both ways.
Before committing your migrations you should run your migrations up, down, and then up again to see if migrations are working properly both ways.
(e.g. if you created a table in a migration but reverse migration did not delete it, you will encounter an error when running the forward migration again)
It's also worth checking your migrations in a separate, containerized environment. You can find some tools at the [end of this document](#further-reading).

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SOURCE ?= file go_bindata github github_ee bitbucket aws_s3 google_cloud_storage godoc_vfs gitlab
DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb yugabytedb clickhouse mongodb sqlserver firebird neo4j pgx pgx5
DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb yugabytedb clickhouse mongodb sqlserver firebird neo4j pgx pgx5 rqlite
DATABASE_TEST ?= $(DATABASE) sqlite sqlite3 sqlcipher
VERSION ?= $(shell git describe --tags 2>/dev/null | cut -c 2-)
TEST_FLAGS ?=
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.19%2C%201.20-lightgrey.svg)
![Supported Go Versions](https://img.shields.io/badge/Go-1.24%2C%201.25-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)

Expand All @@ -28,11 +28,11 @@ Database drivers run migrations. [Add a new database?](database/driver.go)
* [PGX v5](database/pgx/v5)
* [Redshift](database/redshift)
* [Ql](database/ql)
* [Cassandra](database/cassandra)
* [Cassandra / ScyllaDB](database/cassandra)
* [SQLite](database/sqlite)
* [SQLite3](database/sqlite3) ([todo #165](https://github.com/mattes/migrate/issues/165))
* [SQLCipher](database/sqlcipher)
* [MySQL/ MariaDB](database/mysql)
* [MySQL / MariaDB](database/mysql)
* [Neo4j](database/neo4j)
* [MongoDB](database/mongodb)
* [CrateDB](database/crate) ([todo #170](https://github.com/mattes/migrate/issues/170))
Expand All @@ -43,6 +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)

### Database URLs

Expand Down Expand Up @@ -86,7 +87,7 @@ Source drivers read migrations from local or remote sources. [Add a new source?]
* Handles ctrl+c (SIGINT) gracefully.
* No config search paths, no config files, no magic ENV var injections.

__[CLI Documentation](cmd/migrate)__
[CLI Documentation](cmd/migrate) (includes CLI install instructions)

### Basic usage

Expand Down Expand Up @@ -144,7 +145,7 @@ func main() {
m, err := migrate.NewWithDatabaseInstance(
"file:///migrations",
"postgres", driver)
m.Up() // or m.Step(2) if you want to explicitly set the number of migrations to run
m.Up() // or m.Steps(2) if you want to explicitly set the number of migrations to run
}
```

Expand All @@ -170,6 +171,11 @@ Each migration has an up and down migration. [Why?](FAQ.md#why-two-separate-file

[Best practices: How to write migrations.](MIGRATIONS.md)

## Coming from another db migration tool?

Check out [migradaptor](https://github.com/musinit/migradaptor/).
*Note: migradaptor is not affiliated or supported by this project*

## Versions

Version | Supported? | Import | Notes
Expand Down
20 changes: 12 additions & 8 deletions cmd/migrate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ $ scoop install migrate
### Linux (*.deb package)

```bash
$ curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | apt-key add -
$ echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/migrate.list
$ curl -fsSL https://packagecloud.io/golang-migrate/migrate/gpgkey | sudo gpg --dearmor -o /etc/apt/keyrings/migrate.gpg
$ echo "deb [signed-by=/etc/apt/keyrings/migrate.gpg] https://packagecloud.io/golang-migrate/migrate/ubuntu/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/migrate.list
$ apt-get update
$ apt-get install -y migrate
```
Expand Down Expand Up @@ -86,14 +86,18 @@ Options:
-help Print usage

Commands:
create [-ext E] [-dir D] [-seq] [-digits N] [-format] NAME
Create a set of timestamped up/down migrations titled NAME, in directory D with extension E.
Use -seq option to generate sequential up/down migrations with N digits.
Use -format option to specify a Go time format string.
create [-ext E] [-dir D] [-seq] [-digits N] [-format] [-tz] NAME
Create a set of timestamped up/down migrations titled NAME, in directory D with extension E.
Use -seq option to generate sequential up/down migrations with N digits.
Use -format option to specify a Go time format string. Note: migrations with the same time cause "duplicate migration version" error.
Use -tz option to specify the timezone that will be used when generating non-sequential migrations (defaults: UTC).

goto V Migrate to version V
up [N] Apply all or N up migrations
down [N] Apply all or N down migrations
drop Drop everything inside database
down [N] [-all] Apply all or N down migrations
Use -all to apply all down migrations
drop [-f] Drop everything inside database
Use -f to bypass confirmation
force V Set version V but don't run migration (ignores dirty state)
version Print current migration version
```
Expand Down
11 changes: 8 additions & 3 deletions database/cassandra/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# Cassandra
# Cassandra / ScyllaDB

* Drop command will not work on Cassandra 2.X because it rely on
* `Drop()` method will not work on Cassandra 2.X because it rely on
system_schema table which comes with 3.X
* Other commands should work properly but are **not tested**
* Other methods should work properly but are **not tested**
* The Cassandra driver (gocql) 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.

**ScyllaDB**

* No additional configuration is required since it is a drop-in replacement for Cassandra.
* The `Drop()` method` works for ScyllaDB 5.1


## Usage
`cassandra://host:port/keyspace?param1=value&param2=value2`
Expand Down
16 changes: 5 additions & 11 deletions database/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import (
nurl "net/url"
"strconv"
"strings"
"sync/atomic"
"time"

"go.uber.org/atomic"

"github.com/gocql/gocql"
"github.com/golang-migrate/migrate/v4/database"
"github.com/golang-migrate/migrate/v4/database/multistmt"
"github.com/hashicorp/go-multierror"
)

func init() {
Expand Down Expand Up @@ -199,14 +197,14 @@ func (c *Cassandra) Close() error {
}

func (c *Cassandra) Lock() error {
if !c.isLocked.CAS(false, true) {
if !c.isLocked.CompareAndSwap(false, true) {
return database.ErrLocked
}
return nil
}

func (c *Cassandra) Unlock() error {
if !c.isLocked.CAS(true, false) {
if !c.isLocked.CompareAndSwap(true, false) {
return database.ErrNotLocked
}
return nil
Expand Down Expand Up @@ -316,11 +314,7 @@ func (c *Cassandra) ensureVersionTable() (err error) {

defer func() {
if e := c.Unlock(); e != nil {
if err == nil {
err = e
} else {
err = multierror.Append(err, e)
}
err = errors.Join(err, e)
}
}()

Expand All @@ -342,7 +336,7 @@ func parseConsistency(consistencyStr string) (consistency gocql.Consistency, err
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("Failed to parse consistency \"%s\": %v", consistencyStr, r)
err = fmt.Errorf("failed to parse consistency \"%s\": %v", consistencyStr, r)
}
}
}()
Expand Down
Loading