aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-06-30 17:07:37 +0200
committerFlorian Dold <florian@dold.me>2024-06-30 17:07:40 +0200
commita4cd488e387979ec221d11d752233facc023beb2 (patch)
tree00472a7b24952de5de49215d6110376ffcd93183 /src
parent547a5cc2f693ad1bc10c805e1bb28000c70e69ad (diff)
fix DB migration
A botched merge modified an old migration file, causing the current merchant to migrate the DB cleanly from old databases.
Diffstat (limited to 'src')
-rw-r--r--src/backenddb/Makefile.am1
-rw-r--r--src/backenddb/merchant-0006.sql6
-rw-r--r--src/backenddb/merchant-0009.sql10
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;