From f9fec7b266e92d56d04db2030ec0bc94ab1d4ee6 Mon Sep 17 00:00:00 2001 From: Niklas Fondberg Date: Mon, 1 Feb 2021 16:31:58 +0100 Subject: [PATCH] P5-6616 Remove market_id and add locale_id to collections (#174) --- migrations/000.293.sql | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 migrations/000.293.sql diff --git a/migrations/000.293.sql b/migrations/000.293.sql new file mode 100644 index 0000000..de7c5a7 --- /dev/null +++ b/migrations/000.293.sql @@ -0,0 +1,28 @@ +-- P5-6616: add locale_id column to collections_texts and populate it + +ALTER TABLE collections_texts ADD column locale_id INTEGER; + +ALTER TABLE collections_texts + add CONSTRAINT locale_fkey + FOREIGN KEY (locale_id) + REFERENCES locales(id) match SIMPLE; + +UPDATE collections_texts SET locale_id = 1 where market_id = 1; +UPDATE collections_texts SET locale_id = 2 where market_id = 2; +UPDATE collections_texts SET locale_id = 3 where market_id = 3; +UPDATE collections_texts SET locale_id = 4 where market_id = 4; +UPDATE collections_texts SET locale_id = 5 where market_id = 5; +UPDATE collections_texts SET locale_id = 7 where market_id = 7; +UPDATE collections_texts SET locale_id = 8 where market_id = 8; +UPDATE collections_texts SET locale_id = 9 where market_id = 9; +UPDATE collections_texts SET locale_id = 10 where market_id = 10; +UPDATE collections_texts SET locale_id = 11 where market_id = 11; +UPDATE collections_texts SET locale_id = 12 where market_id = 12; +UPDATE collections_texts SET locale_id = 13 where market_id = 13; +UPDATE collections_texts SET locale_id = 14 where market_id = 14; +UPDATE collections_texts SET locale_id = 15 where market_id = 15; + +ALTER TABLE collections_texts DROP column market_id; + +ALTER TABLE collections_texts ALTER COLUMN locale_id SET NOT NULL; +ALTER TABLE collections_texts ADD CONSTRAINT unique_slug UNIQUE (locale_id, slug);