Compare commits

..

4 commits

Author SHA1 Message Date
a0def6e86a fix sqlite3 2023-01-18 15:33:22 -03:00
5d55cc1761 rename 2023-01-18 14:15:48 -03:00
siddweiker
34a9ee7d2b
Fix issue with migration when it fails (#3)
Instead of using the transaction to call Exec, the database is used which causes the rollback to not revert the new migration row.
2021-08-18 17:30:04 -04:00
Jon Calhoun
ac09d418c1
Merge pull request #1 from joncalhoun/add-license-1
Create LICENSE
2020-09-16 13:06:43 -04:00
4 changed files with 7 additions and 5 deletions

4
go.mod
View file

@ -1,9 +1,9 @@
module github.com/joncalhoun/migrate
module gitea.nulo.in/Nulo/go-migrate
go 1.14
require (
github.com/jmoiron/sqlx v1.2.0
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/mattn/go-sqlite3 v1.14.16
google.golang.org/appengine v1.6.6 // indirect
)

2
go.sum
View file

@ -6,6 +6,8 @@ github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhB
github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

View file

@ -107,7 +107,7 @@ func (s *Sqlx) runMigration(db *sqlx.DB, m SqlxMigration) error {
if err != nil {
return errorf(err)
}
_, err = db.Exec("INSERT INTO migrations (id) VALUES ($1)", m.ID)
_, err = tx.Exec("INSERT INTO migrations (id) VALUES ($1)", m.ID)
if err != nil {
tx.Rollback()
return errorf(err)
@ -131,7 +131,7 @@ func (s *Sqlx) runRollback(db *sqlx.DB, m SqlxMigration) error {
if err != nil {
return errorf(err)
}
_, err = db.Exec("DELETE FROM migrations WHERE id=$1", m.ID)
_, err = tx.Exec("DELETE FROM migrations WHERE id=$1", m.ID)
if err != nil {
tx.Rollback()
return errorf(err)

View file

@ -5,7 +5,7 @@ import (
"fmt"
"testing"
"github.com/joncalhoun/migrate"
"gitea.nulo.in/Nulo/go-migrate"
_ "github.com/mattn/go-sqlite3"
)