Add checkbox tables to editorial_content (#397)

* added migration

* fixed boolean
This commit is contained in:
Arwid Thornström
2024-05-02 11:01:30 +02:00
committed by GitHub
parent 278f1e14a1
commit 1eeeb515a0
+16
View File
@@ -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;