mirror of https://github.com/status-im/migrate.git
postgres: fix SetVersion. All requests were executed in different connections so commit/rollback doesn't work correctly
This commit is contained in:
parent
8cd9761d29
commit
94056e51cc
|
@ -176,14 +176,14 @@ func (p *Postgres) SetVersion(version int, dirty bool) error {
|
|||
}
|
||||
|
||||
query := `TRUNCATE "` + p.config.MigrationsTable + `"`
|
||||
if _, err := p.db.Exec(query); err != nil {
|
||||
if _, err := tx.Exec(query); err != nil {
|
||||
tx.Rollback()
|
||||
return &database.Error{OrigErr: err, Query: []byte(query)}
|
||||
}
|
||||
|
||||
if version >= 0 {
|
||||
query = `INSERT INTO "` + p.config.MigrationsTable + `" (version, dirty) VALUES ($1, $2)`
|
||||
if _, err := p.db.Exec(query, version, dirty); err != nil {
|
||||
if _, err := tx.Exec(query, version, dirty); err != nil {
|
||||
tx.Rollback()
|
||||
return &database.Error{OrigErr: err, Query: []byte(query)}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue