From 1eeeb515a041f920519cc04d4bc49ed9ab8ec640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arwid=20Thornstr=C3=B6m?= Date: Thu, 2 May 2024 11:01:30 +0200 Subject: [PATCH] Add checkbox tables to editorial_content (#397) * added migration * fixed boolean --- migrations/000.475.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 migrations/000.475.sql diff --git a/migrations/000.475.sql b/migrations/000.475.sql new file mode 100644 index 0000000..75bfe64 --- /dev/null +++ b/migrations/000.475.sql @@ -0,0 +1,16 @@ +-- Add the new columns 'add_to_menu' and 'menu_title' to the 'editorial_content' table +ALTER TABLE editorial_content +ADD COLUMN add_to_menu BOOLEAN DEFAULT FALSE, +ADD COLUMN menu_title TEXT; + +-- Add a new column 'visible' to the 'editorial_content' table +ALTER TABLE editorial_content ADD COLUMN IF NOT EXISTS visible BOOL NOT NULL DEFAULT TRUE; + +-- Update all existing rows to set the value of the 'add_to_menu' column to FALSE +UPDATE editorial_content +SET add_to_menu = FALSE; + +-- Create a unique partial index to enforce the constraint +CREATE UNIQUE INDEX unique_add_to_menu_per_locale +ON editorial_content (market_locale_id) +WHERE add_to_menu = TRUE;