From dac29c1786a1d0275aa91dcc631934ffa8cfb722 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Mon, 21 Feb 2022 16:43:28 +0100 Subject: [PATCH] Split migrations in to two statements --- .../deltas/2022021414375800_add_policy_version.go | 8 ++++++-- .../sqlite3/deltas/2022021414375800_add_policy_version.go | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/userapi/storage/postgres/deltas/2022021414375800_add_policy_version.go b/userapi/storage/postgres/deltas/2022021414375800_add_policy_version.go index 10b1006df..27347d21c 100644 --- a/userapi/storage/postgres/deltas/2022021414375800_add_policy_version.go +++ b/userapi/storage/postgres/deltas/2022021414375800_add_policy_version.go @@ -12,11 +12,15 @@ func LoadAddPolicyVersion(m *sqlutil.Migrations) { } func UpAddPolicyVersion(tx *sql.Tx) error { - _, err := tx.Exec("ALTER TABLE account_accounts ADD COLUMN IF NOT EXISTS policy_version TEXT;" + - "ALTER TABLE account_accounts ADD COLUMN IF NOT EXISTS policy_version_sent TEXT;") + _, err := tx.Exec("ALTER TABLE account_accounts ADD COLUMN IF NOT EXISTS policy_version TEXT;") if err != nil { return fmt.Errorf("failed to execute upgrade: %w", err) } + _, err = tx.Exec("ALTER TABLE account_accounts ADD COLUMN IF NOT EXISTS policy_version_sent TEXT;") + if err != nil { + return fmt.Errorf("failed to execute upgrade: %w", err) + } + return nil } diff --git a/userapi/storage/sqlite3/deltas/2022021414375800_add_policy_version.go b/userapi/storage/sqlite3/deltas/2022021414375800_add_policy_version.go index 2292b9031..683210ca7 100644 --- a/userapi/storage/sqlite3/deltas/2022021414375800_add_policy_version.go +++ b/userapi/storage/sqlite3/deltas/2022021414375800_add_policy_version.go @@ -12,8 +12,11 @@ func LoadAddPolicyVersion(m *sqlutil.Migrations) { } func UpAddPolicyVersion(tx *sql.Tx) error { - _, err := tx.Exec("ALTER TABLE account_accounts ADD COLUMN policy_version TEXT;" + - "ALTER TABLE account_accounts ADD COLUMN policy_version_sent TEXT;") + _, err := tx.Exec("ALTER TABLE account_accounts ADD COLUMN policy_version TEXT;") + if err != nil { + return fmt.Errorf("failed to execute upgrade: %w", err) + } + _, err = tx.Exec("ALTER TABLE account_accounts ADD COLUMN policy_version_sent TEXT;") if err != nil { return fmt.Errorf("failed to execute upgrade: %w", err) }