-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
For running all migrations in a global transaction, the README suggests code like the following:
var oldVersion, newVersion int64
err = db.RunInTransaction(func(tx *pg.Tx) error {
oldVersion, newVersion, err = migrations.Run(tx, flag.Args()...)
return err
})
if err != nil {
panic(err)
}After upgrading from v6.2.0 to v6.7.3, the code now fails:
BEGIN
SELECT count(*) FROM "pg_tables" WHERE (schemaname = 'public') AND (tablename = 'gopg_migrations')
SET idle_in_transaction_session_timeout = 0
LOCK TABLE gopg_migrations
SELECT version FROM gopg_migrations ORDER BY id DESC LIMIT 1
COMMIT
panic: pg: transaction has already been committed or rolled back
I don't see nested transactions in the output, but it does look like the code will attempt to create a transaction for each migration: https://github.com/go-pg/migrations/blob/master/collection.go#L454
jmattheis and geigi
Metadata
Metadata
Assignees
Labels
No labels