diff --git a/migrations/000.261.sql b/migrations/000.261.sql new file mode 100644 index 0000000..09c6a2a --- /dev/null +++ b/migrations/000.261.sql @@ -0,0 +1,20 @@ +-- P5-6245: add market id to product blacklist table + +alter table product_blacklist + add column market_id integer; + +alter table product_blacklist + add constraint market_fkey + foreign key (market_id) + references markets(id) match simple; + +update product_blacklist SET market_id = ( + select markets.id from markets + join locales on markets.locale_id = locales.id + where locales.value = product_blacklist.language_id || '_' || product_blacklist.territory_id +); + +alter table product_blacklist + alter column market_id set not null; + +create unique index on product_blacklist (product_id, group_id, market_id);