-- 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);