From 09833ed9c5483e57d82f34ec0d582a61f8827c0b Mon Sep 17 00:00:00 2001 From: Martin Carlsson Date: Thu, 14 Jan 2021 16:31:07 +0100 Subject: [PATCH] P5-6492 move price_adjustments to markets table (#169) --- migrations/000.286.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 migrations/000.286.sql diff --git a/migrations/000.286.sql b/migrations/000.286.sql new file mode 100644 index 0000000..942239a --- /dev/null +++ b/migrations/000.286.sql @@ -0,0 +1,14 @@ +-- P5-6492: copy price adjustments to market table + +alter table markets + add column price_adjustment numeric not null default 1; + + +update markets +set price_adjustment = x.adjustment +from ( + select adjustment, locales.id as locale_id + from price_adjustments + join locales on price_adjustments.territory = substr(locales.value, 4) +) x +where x.locale_id = markets.locale_id;