From 39978717aee6890f25f57b8e011fd350a2b72ab9 Mon Sep 17 00:00:00 2001 From: Manfred Touron <94029+moul@users.noreply.github.com> Date: Wed, 3 Jun 2020 13:42:53 +0200 Subject: [PATCH] fix: run migrations in transactions Addresses #511 --- go/pkg/pwdb/migrations.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go/pkg/pwdb/migrations.go b/go/pkg/pwdb/migrations.go index 227a96cbd..156d0c6f5 100644 --- a/go/pkg/pwdb/migrations.go +++ b/go/pkg/pwdb/migrations.go @@ -8,7 +8,9 @@ import ( ) func migrate(db *gorm.DB, sfn *snowflake.Node, opts Opts) error { - m := gormigrate.New(db, gormigrate.DefaultOptions, []*gormigrate.Migration{}) + migrateOpts := gormigrate.DefaultOptions + migrateOpts.UseTransaction = true + m := gormigrate.New(db, migrateOpts, []*gormigrate.Migration{}) // only called on fresh database m.InitSchema(func(tx *gorm.DB) error {