Skip to content

Commit fcbc186

Browse files
adnxngouthamve
authored andcommitted
Upgrade golang-migrate/migrate to v4 (#1384) (#1802)
Signed-off-by: adnan <[email protected]>
1 parent 6c63039 commit fcbc186

Some content is hidden

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

103 files changed

+6475
-2194
lines changed

go.mod

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,37 @@ require (
1111
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4
1212
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878
1313
github.com/aws/aws-sdk-go v1.25.22
14-
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 // indirect
1514
github.com/blang/semver v3.5.0+incompatible
16-
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
1715
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668
1816
github.com/cenkalti/backoff v1.0.0 // indirect
1917
github.com/cespare/xxhash v1.1.0
2018
github.com/coreos/go-semver v0.3.0 // indirect
2119
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d // indirect
2220
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
23-
github.com/cznic/ql v1.2.0 // indirect
2421
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb
2522
github.com/fluent/fluent-logger-golang v1.2.1 // indirect
26-
github.com/fsouza/fake-gcs-server v1.3.0
23+
github.com/fsouza/fake-gcs-server v1.7.0
2724
github.com/go-kit/kit v0.9.0
28-
github.com/gocql/gocql v0.0.0-20180113133114-697e7c57f99b
25+
github.com/gocql/gocql v0.0.0-20190301043612-f6df8288f9b4
2926
github.com/gogo/googleapis v1.1.0 // indirect
3027
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48
3128
github.com/gogo/status v1.0.3
29+
github.com/golang-migrate/migrate/v4 v4.7.0
3230
github.com/golang/protobuf v1.3.2
3331
github.com/golang/snappy v0.0.1
3432
github.com/gomodule/redigo v2.0.0+incompatible
35-
github.com/gorilla/context v1.1.1 // indirect
36-
github.com/gorilla/mux v1.6.2
33+
github.com/gorilla/mux v1.7.1
3734
github.com/gorilla/websocket v1.4.0 // indirect
3835
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0
39-
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
4036
github.com/hashicorp/consul/api v1.1.0
4137
github.com/hashicorp/go-cleanhttp v0.5.1
4238
github.com/hashicorp/go-sockaddr v1.0.2
4339
github.com/hashicorp/memberlist v0.1.4
4440
github.com/json-iterator/go v1.1.7
45-
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
4641
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 // indirect
4742
github.com/lann/builder v0.0.0-20150808151131-f22ce00fd939 // indirect
4843
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
4944
github.com/lib/pq v1.0.0
50-
github.com/mattes/migrate v1.3.1
51-
github.com/mattn/go-sqlite3 v1.10.0 // indirect
5245
github.com/oklog/ulid v1.3.1
5346
github.com/opentracing-contrib/go-grpc v0.0.0-20180928155321-4b5a12d3ff02
5447
github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9
@@ -60,7 +53,6 @@ require (
6053
github.com/prometheus/common v0.7.0
6154
github.com/prometheus/prometheus v1.8.2-0.20190918104050-8744afdd1ea0
6255
github.com/rafaeljusto/redigomock v0.0.0-20190202135759-257e089e14a1
63-
github.com/satori/go.uuid v1.2.0 // indirect
6456
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e
6557
github.com/sercand/kuberesolver v2.1.0+incompatible // indirect
6658
github.com/spf13/afero v1.2.2

go.sum

Lines changed: 86 additions & 63 deletions
Large diffs are not rendered by default.

pkg/configs/db/dbtest/integration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func Setup(t *testing.T) db.DB {
3939
// Don't use db.MustNew, here so we can do a transaction around the whole test, to rollback.
4040
pg, err := postgres.New(
4141
fmt.Sprintf("postgres://postgres@%s/configs_test?sslmode=disable", dbAddr),
42-
migrationsDir,
42+
fmt.Sprintf("file:%s", migrationsDir),
4343
)
4444
require.NoError(t, err)
4545

pkg/configs/db/postgres/postgres.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import (
1111
"github.com/cortexproject/cortex/pkg/configs"
1212
"github.com/cortexproject/cortex/pkg/util"
1313
"github.com/go-kit/kit/log/level"
14+
"github.com/golang-migrate/migrate/v4"
15+
_ "github.com/golang-migrate/migrate/v4/database/postgres" // Import the postgres migrations driver
16+
_ "github.com/golang-migrate/migrate/v4/source/file" // Import the postgres migrations driver
1417
"github.com/lib/pq"
15-
_ "github.com/lib/pq" // Import the postgres sql driver
16-
_ "github.com/mattes/migrate/driver/postgres" // Import the postgres migrations driver
17-
"github.com/mattes/migrate/migrate"
18+
_ "github.com/lib/pq" // Import the postgres sql driver
1819
"github.com/pkg/errors"
1920
)
2021

@@ -74,12 +75,18 @@ func New(uri, migrationsDir string) (DB, error) {
7475
}
7576

7677
if migrationsDir != "" {
78+
m, err := migrate.New(migrationsDir, uri)
79+
if err != nil {
80+
return DB{}, errors.Wrap(err, "database migrations initialization failed")
81+
}
82+
7783
level.Info(util.Logger).Log("msg", "running database migrations...")
78-
if errs, ok := migrate.UpSync(uri, migrationsDir); !ok {
79-
for _, err := range errs {
80-
level.Error(util.Logger).Log("err", err)
84+
85+
if err := m.Up(); err != nil {
86+
if err != migrate.ErrNoChange {
87+
return DB{}, errors.Wrap(err, "database migrations failed")
8188
}
82-
return DB{}, errors.New("database migrations failed")
89+
level.Debug(util.Logger).Log("msg", "no change in schema, error (ignored)", "error", err)
8390
}
8491
}
8592

vendor/github.com/armon/go-metrics/prometheus/prometheus.go

Lines changed: 194 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/fsouza/fake-gcs-server/LICENSE

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/fsouza/fake-gcs-server/fakestorage/mux_tranport.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/fsouza/fake-gcs-server/fakestorage/object.go

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)