-- 0099_brand_hero_video.sql
-- Add an optional hero_video_url column to brand_settings so each brand can
-- point its storefront hero at any video URL (CDN, signed S3, Supabase
-- storage, etc.) without a code change. When unset or unplayable, the
-- storefront hero falls back to hero_image_url.
--
-- We intentionally avoid touching the `upsert_brand_settings(...)`
-- SECURITY DEFINER RPC here — its 32-parameter positional signature is
-- already deployed in production. New value writes use a separate
-- idempotent statement.

ALTER TABLE brand_settings
  ADD COLUMN IF NOT EXISTS hero_video_url TEXT;

COMMENT ON COLUMN brand_settings.hero_video_url IS
  'Optional. Direct URL to a hero background video (mp4/webm). When null or 4xx/5xx, storefront falls back to hero_image_url as a still poster.';

-- Make sure new column is visible to consumers that read brand_settings.
GRANT SELECT ON brand_settings TO anon, authenticated;
