Skip to content

Upgrade golang-migrate/migrate to v4 (#1384) #1802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 4 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,38 @@ require (
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878
github.com/aws/aws-sdk-go v1.25.22
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 // indirect
github.com/blang/semver v3.5.0+incompatible
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668
github.com/cenkalti/backoff v1.0.0 // indirect
github.com/cespare/xxhash v1.1.0
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/cznic/ql v1.2.0 // indirect
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb
github.com/fluent/fluent-logger-golang v1.2.1 // indirect
github.com/fsouza/fake-gcs-server v1.3.0
github.com/fsouza/fake-gcs-server v1.7.0
github.com/go-kit/kit v0.9.0
github.com/gocql/gocql v0.0.0-20180113133114-697e7c57f99b
github.com/gocql/gocql v0.0.0-20190301043612-f6df8288f9b4
github.com/gogo/googleapis v1.1.0 // indirect
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48
github.com/gogo/status v1.0.3
github.com/golang-migrate/migrate/v4 v4.7.0
github.com/golang/protobuf v1.3.2
github.com/golang/snappy v0.0.1
github.com/gomodule/redigo v2.0.0+incompatible
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/mux v1.6.2
github.com/gorilla/mux v1.7.1
github.com/gorilla/websocket v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/consul/api v1.1.0
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/hashicorp/go-sockaddr v1.0.2
github.com/hashicorp/memberlist v0.1.4
github.com/jonboulle/clockwork v0.1.0
github.com/json-iterator/go v1.1.7
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 // indirect
github.com/lann/builder v0.0.0-20150808151131-f22ce00fd939 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lib/pq v1.0.0
github.com/mattes/migrate v1.3.1
github.com/mattn/go-sqlite3 v1.10.0 // indirect
github.com/oklog/ulid v1.3.1
github.com/opentracing-contrib/go-grpc v0.0.0-20180928155321-4b5a12d3ff02
github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9
Expand All @@ -61,7 +54,6 @@ require (
github.com/prometheus/common v0.7.0
github.com/prometheus/prometheus v1.8.2-0.20190918104050-8744afdd1ea0
github.com/rafaeljusto/redigomock v0.0.0-20190202135759-257e089e14a1
github.com/satori/go.uuid v1.2.0 // indirect
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e
github.com/sercand/kuberesolver v2.1.0+incompatible // indirect
github.com/stretchr/testify v1.4.0
Expand Down
149 changes: 86 additions & 63 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/configs/db/dbtest/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func Setup(t *testing.T) db.DB {
// Don't use db.MustNew, here so we can do a transaction around the whole test, to rollback.
pg, err := postgres.New(
fmt.Sprintf("postgres://postgres@%s/configs_test?sslmode=disable", dbAddr),
migrationsDir,
fmt.Sprintf("file:%s", migrationsDir),
)
require.NoError(t, err)

Expand Down
21 changes: 14 additions & 7 deletions pkg/configs/db/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (
"github.com/cortexproject/cortex/pkg/configs"
"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log/level"
"github.com/golang-migrate/migrate/v4"
_ "github.com/golang-migrate/migrate/v4/database/postgres" // Import the postgres migrations driver
_ "github.com/golang-migrate/migrate/v4/source/file" // Import the postgres migrations driver
"github.com/lib/pq"
_ "github.com/lib/pq" // Import the postgres sql driver
_ "github.com/mattes/migrate/driver/postgres" // Import the postgres migrations driver
"github.com/mattes/migrate/migrate"
_ "github.com/lib/pq" // Import the postgres sql driver
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -74,12 +75,18 @@ func New(uri, migrationsDir string) (DB, error) {
}

if migrationsDir != "" {
m, err := migrate.New(migrationsDir, uri)
if err != nil {
return DB{}, errors.Wrap(err, "database migrations initialization failed")
}

level.Info(util.Logger).Log("msg", "running database migrations...")
if errs, ok := migrate.UpSync(uri, migrationsDir); !ok {
for _, err := range errs {
level.Error(util.Logger).Log("err", err)

if err := m.Up(); err != nil {
if err != migrate.ErrNoChange {
return DB{}, errors.Wrap(err, "database migrations failed")
}
return DB{}, errors.New("database migrations failed")
level.Debug(util.Logger).Log("msg", "no change in schema, error (ignored)", "error", err)
}
}

Expand Down
194 changes: 194 additions & 0 deletions vendor/github.com/armon/go-metrics/prometheus/prometheus.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/fsouza/fake-gcs-server/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions vendor/github.com/fsouza/fake-gcs-server/fakestorage/object.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading