From a4cd488e387979ec221d11d752233facc023beb2 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 30 Jun 2024 17:07:37 +0200 Subject: fix DB migration A botched merge modified an old migration file, causing the current merchant to migrate the DB cleanly from old databases. --- src/backenddb/Makefile.am | 1 + src/backenddb/merchant-0006.sql | 6 ------ src/backenddb/merchant-0009.sql | 10 ++++++++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am index e6511fef..52737c2b 100644 --- a/src/backenddb/Makefile.am +++ b/src/backenddb/Makefile.am @@ -25,6 +25,7 @@ sql_DATA = \ merchant-0006.sql \ merchant-0007.sql \ merchant-0008.sql \ + merchant-0009.sql \ drop.sql BUILT_SOURCES = \ diff --git a/src/backenddb/merchant-0006.sql b/src/backenddb/merchant-0006.sql index e216b4ad..81a4e656 100644 --- a/src/backenddb/merchant-0006.sql +++ b/src/backenddb/merchant-0006.sql @@ -26,12 +26,6 @@ SELECT _v.register_patch('merchant-0006', NULL, NULL); SET search_path TO merchant; -ALTER TABLE merchant_contract_terms - ADD COLUMN choice_index INT2 DEFAULT NULL; - -COMMENT ON COLUMN merchant_contract_terms.choice_index - IS 'Index of selected choice. Refers to the `choices` array in the contract terms. NULL for contracts without choices.'; - ALTER TABLE merchant_inventory ALTER COLUMN image SET DATA TYPE TEXT; diff --git a/src/backenddb/merchant-0009.sql b/src/backenddb/merchant-0009.sql index babecf93..988a01c6 100644 --- a/src/backenddb/merchant-0009.sql +++ b/src/backenddb/merchant-0009.sql @@ -29,5 +29,15 @@ SET search_path TO merchant; ALTER TABLE merchant_template DROP COLUMN required_currency; +-- Add the column with IF NOT EXISTS since this +-- migration accidentally was in merchant-0006.sql +-- for some time before it was moved here. +ALTER TABLE merchant_contract_terms + ADD COLUMN IF NOT EXISTS choice_index INT2 DEFAULT NULL; + +COMMENT ON COLUMN merchant_contract_terms.choice_index + IS 'Index of selected choice. Refers to the `choices` array in the contract terms. NULL for contracts without choices.'; + + -- Complete transaction COMMIT; -- cgit v1.2.3