Skip to content

Commit 19c4891

Browse files
authored
Merge branch 'master' into add-with-connection-to-postgres
2 parents f621644 + 3e43c42 commit 19c4891

File tree

9 files changed

+142
-70
lines changed

9 files changed

+142
-70
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ $
6868
Source drivers read migrations from local or remote sources. [Add a new source?](source/driver.go)
6969

7070
* [Filesystem](source/file) - read from filesystem
71+
* [io/fs](source/iofs) - read from a Go [io/fs](https://pkg.go.dev/io/fs#FS)
7172
* [Go-Bindata](source/go_bindata) - read from embedded binary data ([jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata))
7273
* [pkger](source/pkger) - read from embedded binary data ([markbates/pkger](https://github.com/markbates/pkger))
7374
* [GitHub](source/github) - read from remote GitHub repositories
@@ -141,7 +142,7 @@ func main() {
141142
m, err := migrate.NewWithDatabaseInstance(
142143
"file:///migrations",
143144
"postgres", driver)
144-
m.Steps(2)
145+
m.Up() // or m.Step(2) if you want to explicitly set the number of migrations to run
145146
}
146147
```
147148

database/mysql/mysql.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,12 @@ func (m *Mysql) Run(migration io.Reader) error {
336336
}
337337

338338
func (m *Mysql) SetVersion(version int, dirty bool) error {
339-
tx, err := m.conn.BeginTx(context.Background(), &sql.TxOptions{})
339+
tx, err := m.conn.BeginTx(context.Background(), &sql.TxOptions{Isolation: sql.LevelSerializable})
340340
if err != nil {
341341
return &database.Error{OrigErr: err, Err: "transaction start failed"}
342342
}
343343

344-
query := "TRUNCATE `" + m.config.MigrationsTable + "`"
344+
query := "DELETE FROM `" + m.config.MigrationsTable + "`"
345345
if _, err := tx.ExecContext(context.Background(), query); err != nil {
346346
if errRollback := tx.Rollback(); errRollback != nil {
347347
err = multierror.Append(err, errRollback)

go.mod

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
module github.com/golang-migrate/migrate/v4
22

33
require (
4-
cloud.google.com/go/spanner v1.24.0
4+
cloud.google.com/go v0.99.0 // indirect
5+
cloud.google.com/go/spanner v1.28.0
56
cloud.google.com/go/storage v1.10.0
67
github.com/Azure/go-autorest/autorest/adal v0.9.16
78
github.com/ClickHouse/clickhouse-go v1.4.3
8-
github.com/Microsoft/go-winio v0.5.0 // indirect
99
github.com/apache/arrow/go/arrow v0.0.0-20211013220434-5962184e7a30 // indirect
1010
github.com/aws/aws-sdk-go v1.17.7
1111
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.5.4 // indirect
12-
github.com/cenkalti/backoff/v4 v4.0.2
12+
github.com/cenkalti/backoff/v4 v4.1.1
13+
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
14+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
15+
github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490 // indirect
1316
github.com/cockroachdb/cockroach-go/v2 v2.1.1
1417
github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 // indirect
1518
github.com/denisenkom/go-mssqldb v0.10.0
16-
github.com/dhui/dktest v0.3.7
17-
github.com/docker/docker v20.10.9+incompatible
19+
github.com/dhui/dktest v0.3.9
20+
github.com/docker/docker v20.10.12+incompatible
1821
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 // indirect
22+
github.com/envoyproxy/go-control-plane v0.10.1 // indirect
23+
github.com/envoyproxy/protoc-gen-validate v0.6.2 // indirect
1924
github.com/fsouza/fake-gcs-server v1.17.0
2025
github.com/gabriel-vasile/mimetype v1.4.0 // indirect
2126
github.com/go-sql-driver/mysql v1.5.0
2227
github.com/gobuffalo/here v0.6.0
2328
github.com/gocql/gocql v0.0.0-20210515062232-b7ef815b4556
2429
github.com/gofrs/uuid v4.0.0+incompatible // indirect
2530
github.com/golang-jwt/jwt/v4 v4.1.0 // indirect
31+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
2632
github.com/google/go-github/v39 v39.2.0
2733
github.com/gorilla/mux v1.7.4 // indirect
2834
github.com/hashicorp/go-multierror v1.1.0
@@ -35,7 +41,7 @@ require (
3541
github.com/ktrysmt/go-bitbucket v0.6.4
3642
github.com/lib/pq v1.10.0
3743
github.com/markbates/pkger v0.15.1
38-
github.com/mattn/go-sqlite3 v1.14.6
44+
github.com/mattn/go-sqlite3 v1.14.10
3945
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
4046
github.com/mutecomm/go-sqlcipher/v4 v4.4.0
4147
github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8
@@ -48,13 +54,10 @@ require (
4854
go.mongodb.org/mongo-driver v1.7.0
4955
go.uber.org/atomic v1.6.0
5056
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
51-
golang.org/x/net v0.0.0-20211013171255-e13a2654a71e // indirect
52-
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
53-
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect
57+
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
5458
golang.org/x/tools v0.1.5
55-
google.golang.org/api v0.51.0
56-
google.golang.org/genproto v0.0.0-20211013025323-ce878158c4d4
57-
google.golang.org/grpc v1.41.0 // indirect
59+
google.golang.org/api v0.62.0
60+
google.golang.org/genproto v0.0.0-20220111164026-67b88f271998
5861
modernc.org/b v1.0.0 // indirect
5962
modernc.org/db v1.0.0 // indirect
6063
modernc.org/file v1.0.0 // indirect

0 commit comments

Comments
 (0)