From 3ade6376b17f4080b5c991c64ed7a7f0f518b189 Mon Sep 17 00:00:00 2001 From: Martin Carlsson Date: Tue, 2 Feb 2021 10:49:12 +0100 Subject: [PATCH] P5-6514 use market_locale_id for redirects (#173) --- migrations/000.294.sql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 migrations/000.294.sql diff --git a/migrations/000.294.sql b/migrations/000.294.sql new file mode 100644 index 0000000..9969ebb --- /dev/null +++ b/migrations/000.294.sql @@ -0,0 +1,23 @@ +-- P5-6514: use market_locale_id for redirects + +alter table redirects + add column market_locale_id integer; + + +alter table redirects + add constraint market_locale_id_fkey + foreign key (market_locale_id) + references market_locales(id) match simple; + + +update redirects set market_locale_id = ( + select id from market_locales where market_id = redirects.market_id +); + + +alter table redirects + alter column market_locale_id set not null; + + +alter table redirects + drop column market_id;