From a09ff8cc6f15bd05f8a4f3b84ffee3da030bbb07 Mon Sep 17 00:00:00 2001 From: Martin Carlsson Date: Thu, 4 Feb 2021 07:24:01 +0100 Subject: [PATCH] P5-6095 replace market with market_locale for articles_content (#149) --- migrations/000.299.sql | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 migrations/000.299.sql diff --git a/migrations/000.299.sql b/migrations/000.299.sql new file mode 100644 index 0000000..72b7cc7 --- /dev/null +++ b/migrations/000.299.sql @@ -0,0 +1,26 @@ +-- P5-6095: articles content should belong to a market_locale + +alter table article_content + add column market_locale_id integer; + + +alter table article_content + add constraint market_locales_fkey + foreign key (market_locale_id) + references market_locales(id) match simple; + + +alter table article_content + add unique (article_id, market_locale_id); + + +update article_content + set market_locale_id = (select id from market_locales where market_id = article_content.market_id); + + +alter table article_content + alter column market_locale_id set not null; + + +alter table article_content + drop column market_id;