Skip to content

Commit 7351dcb

Browse files
committed
Merge branch 'master' into ib
2 parents c84938c + 8b9c5f7 commit 7351dcb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+432
-500
lines changed

.github/workflows/ci.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,24 @@ on:
55
pull_request:
66

77
jobs:
8+
lint:
9+
name: lint
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-go@v5
14+
with:
15+
go-version: "1.25.x"
16+
- name: golangci-lint
17+
uses: golangci/golangci-lint-action@v6
18+
with:
19+
version: v1.64.8
20+
821
test:
922
runs-on: ubuntu-latest
1023
strategy:
1124
matrix:
12-
go: ["1.24.x"]
25+
go: ["1.24.x", "1.25.x"]
1326
steps:
1427
- uses: actions/checkout@v4
1528

@@ -55,7 +68,7 @@ jobs:
5568
ruby-version: 2.7
5669
- uses: actions/setup-go@v5
5770
with:
58-
go-version: "1.22.x"
71+
go-version: "1.24.x"
5972

6073
- uses: docker/setup-qemu-action@v3
6174
- uses: docker/setup-buildx-action@v3
@@ -84,6 +97,9 @@ jobs:
8497
- run: package_cloud push golang-migrate/migrate/ubuntu/jammy dist/migrate.linux-amd64.deb
8598
env:
8699
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
100+
- run: package_cloud push golang-migrate/migrate/ubuntu/noble dist/migrate.linux-amd64.deb
101+
env:
102+
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
87103
- run: package_cloud push golang-migrate/migrate/debian/buster dist/migrate.linux-amd64.deb
88104
env:
89105
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ linters:
1313
- unparam
1414
- nakedret
1515
- prealloc
16+
- revive
1617
#- gosec
1718
linters-settings:
1819
misspell:
1920
locale: US
21+
revive:
22+
rules:
23+
- name: redundant-build-tag
2024
issues:
2125
max-same-issues: 0
2226
max-issues-per-linter: 0

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24-alpine AS builder
1+
FROM golang:1.24-alpine3.21 AS builder
22
ARG VERSION
33

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

1616
RUN make build-docker
1717

18-
FROM scratch
18+
FROM gcr.io/distroless/static:nonroot
1919

2020
COPY --from=builder /go/src/github.com/infobloxopen/migrate/cmd/migrate/config /cli/config/
2121
COPY --from=builder /go/src/github.com/infobloxopen/migrate/build/migrate.linux-386 /migrate

FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
and then "force" the expected version.
6666

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

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Coverage Status](https://img.shields.io/coveralls/github/golang-migrate/migrate/master.svg)](https://coveralls.io/github/golang-migrate/migrate?branch=master)
44
[![packagecloud.io](https://img.shields.io/badge/deb-packagecloud.io-844fec.svg)](https://packagecloud.io/golang-migrate/migrate?filter=debs)
55
[![Docker Pulls](https://img.shields.io/docker/pulls/migrate/migrate.svg)](https://hub.docker.com/r/migrate/migrate/)
6-
![Supported Go Versions](https://img.shields.io/badge/Go-1.21%2C%201.22-lightgrey.svg)
6+
![Supported Go Versions](https://img.shields.io/badge/Go-1.24%2C%201.25-lightgrey.svg)
77
[![GitHub Release](https://img.shields.io/github/release/golang-migrate/migrate.svg)](https://github.com/golang-migrate/migrate/releases)
88
[![Go Report Card](https://goreportcard.com/badge/github.com/golang-migrate/migrate/v4)](https://goreportcard.com/report/github.com/golang-migrate/migrate/v4)
99

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

90-
__[CLI Documentation](cmd/migrate)__
90+
[CLI Documentation](cmd/migrate) (includes CLI install instructions)
9191

9292
### Basic usage
9393

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

cmd/migrate/README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ $ scoop install migrate
2727
### Linux (*.deb package)
2828

2929
```bash
30-
$ curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | apt-key add -
31-
$ echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/migrate.list
30+
$ curl -fsSL https://packagecloud.io/golang-migrate/migrate/gpgkey | sudo gpg --dearmor -o /etc/apt/keyrings/migrate.gpg
31+
$ 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
3232
$ apt-get update
3333
$ apt-get install -y migrate
3434
```
@@ -86,14 +86,18 @@ Options:
8686
-help Print usage
8787

8888
Commands:
89-
create [-ext E] [-dir D] [-seq] [-digits N] [-format] NAME
90-
Create a set of timestamped up/down migrations titled NAME, in directory D with extension E.
91-
Use -seq option to generate sequential up/down migrations with N digits.
92-
Use -format option to specify a Go time format string.
89+
create [-ext E] [-dir D] [-seq] [-digits N] [-format] [-tz] NAME
90+
Create a set of timestamped up/down migrations titled NAME, in directory D with extension E.
91+
Use -seq option to generate sequential up/down migrations with N digits.
92+
Use -format option to specify a Go time format string. Note: migrations with the same time cause "duplicate migration version" error.
93+
Use -tz option to specify the timezone that will be used when generating non-sequential migrations (defaults: UTC).
94+
9395
goto V Migrate to version V
9496
up [N] Apply all or N up migrations
95-
down [N] Apply all or N down migrations
96-
drop Drop everything inside database
97+
down [N] [-all] Apply all or N down migrations
98+
Use -all to apply all down migrations
99+
drop [-f] Drop everything inside database
100+
Use -f to bypass confirmation
97101
force V Set version V but don't run migration (ignores dirty state)
98102
version Print current migration version
99103
```

database/cassandra/cassandra.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import (
77
nurl "net/url"
88
"strconv"
99
"strings"
10+
"sync/atomic"
1011
"time"
1112

12-
"go.uber.org/atomic"
13-
1413
"github.com/gocql/gocql"
1514
"github.com/golang-migrate/migrate/v4/database"
1615
"github.com/golang-migrate/migrate/v4/database/multistmt"
@@ -199,14 +198,14 @@ func (c *Cassandra) Close() error {
199198
}
200199

201200
func (c *Cassandra) Lock() error {
202-
if !c.isLocked.CAS(false, true) {
201+
if !c.isLocked.CompareAndSwap(false, true) {
203202
return database.ErrLocked
204203
}
205204
return nil
206205
}
207206

208207
func (c *Cassandra) Unlock() error {
209-
if !c.isLocked.CAS(true, false) {
208+
if !c.isLocked.CompareAndSwap(true, false) {
210209
return database.ErrNotLocked
211210
}
212211
return nil

database/clickhouse/clickhouse.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import (
77
"net/url"
88
"strconv"
99
"strings"
10+
"sync/atomic"
1011
"time"
1112

12-
"go.uber.org/atomic"
13-
1413
"github.com/golang-migrate/migrate/v4"
1514
"github.com/golang-migrate/migrate/v4/database"
1615
"github.com/golang-migrate/migrate/v4/database/multistmt"
@@ -291,14 +290,14 @@ func (ch *ClickHouse) Drop() (err error) {
291290
}
292291

293292
func (ch *ClickHouse) Lock() error {
294-
if !ch.isLocked.CAS(false, true) {
293+
if !ch.isLocked.CompareAndSwap(false, true) {
295294
return database.ErrLocked
296295
}
297296

298297
return nil
299298
}
300299
func (ch *ClickHouse) Unlock() error {
301-
if !ch.isLocked.CAS(true, false) {
300+
if !ch.isLocked.CompareAndSwap(true, false) {
302301
return database.ErrNotLocked
303302
}
304303

database/clickhouse/clickhouse_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var (
2626
PortRequired: true, ReadyFunc: isReady,
2727
}
2828
specs = []dktesting.ContainerSpec{
29-
{ImageName: "yandex/clickhouse-server:21.3", Options: opts},
29+
{ImageName: "clickhouse:24.8", Options: opts},
3030
}
3131
)
3232

database/cockroachdb/cockroachdb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import (
88
nurl "net/url"
99
"regexp"
1010
"strconv"
11+
"sync/atomic"
1112

1213
"github.com/cockroachdb/cockroach-go/v2/crdb"
1314
"github.com/golang-migrate/migrate/v4"
1415
"github.com/golang-migrate/migrate/v4/database"
1516
"github.com/hashicorp/go-multierror"
1617
"github.com/lib/pq"
17-
"go.uber.org/atomic"
1818
)
1919

2020
func init() {

0 commit comments

Comments
 (0)