From 3193e41bb22bc7988cf26da019d828ae9b9f3536 Mon Sep 17 00:00:00 2001 From: Rudolph Jacobs Date: Thu, 14 Sep 2023 20:44:10 +0200 Subject: [PATCH] Add CockroachDB support. --- migrations.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/migrations.go b/migrations.go index ce6f128..2ac7384 100644 --- a/migrations.go +++ b/migrations.go @@ -61,6 +61,7 @@ func Register(name string, up, down func(*pg.Tx) error) { /* Run Runs the specified command with the options they require Note: + init - no options migrate - one option - "" for all migrations in a single batch @@ -80,7 +81,11 @@ func Run(db *pg.DB, cmd string, options ...string) error { if len(options) > 0 { extra = options[0] } - return migrate(db, extra == "one-by-one") + err := migrate(db, extra == "one-by-one") + if err != nil { + return errors.Wrap(err, "migration failed") + } + return nil case "rollback": return rollback(db) @@ -394,7 +399,7 @@ func lockTable(tx *pg.Tx) error { // https://www.postgresql.org/docs/current/explicit-locking.html // This mode protects a table against concurrent data changes, and is self-exclusive so that only one session can hold it at a time. // This means only one migration can run at a time, but pg_dump can still COPY from the table (since it acquires a ACCESS SHARE lock, or so I am told) - _, err = tx.Exec("LOCK ? in SHARE ROW EXCLUSIVE MODE", pg.Ident(migrationTableName)) + //_, err = tx.Exec("LOCK ? in SHARE ROW EXCLUSIVE MODE", pg.Ident(migrationTableName)) return err }