From 97e61853a7e936327740a3d813d858d8545d6c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arwid=20Thornstr=C3=B6m?= Date: Tue, 26 Mar 2024 11:12:53 +0100 Subject: [PATCH] added migration file (#386) * added migration file * added new constraint * moved file --- migrations/000.471.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 migrations/000.471.sql diff --git a/migrations/000.471.sql b/migrations/000.471.sql new file mode 100644 index 0000000..7e9beb0 --- /dev/null +++ b/migrations/000.471.sql @@ -0,0 +1,9 @@ +-- Add a new column to the editorial_content table +ALTER TABLE editorial_content ADD COLUMN editorial_page_type editorial_type NOT NULL DEFAULT 'campaign'; + +-- Update all editorial_content rows to have the same editorial_page_type as their associated editorial_pages +UPDATE editorial_content ec SET editorial_page_type = ep.type FROM editorial_pages ep WHERE ec.editorial_page_id = ep.id; + +-- We need to update the contraint and add the type to make the id unique since slug can be the same +ALTER TABLE editorial_content DROP CONSTRAINT editorial_content_unique_key; +ALTER TABLE editorial_content ADD CONSTRAINT editorial_content_unique_key UNIQUE (slug, market_locale_id, editorial_page_type);