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