-- =====================================================================
-- 05_profile_avatar.sql  —  RUN THIS ONCE
-- Adds avatar_url support to profiles and ensures app_config supports
-- customized login backgrounds.
--
-- Run: Supabase Dashboard -> SQL Editor -> paste -> Run.
-- =====================================================================

-- 1) Add avatar_url column to profiles and image_url to programs if they don't exist
alter table public.profiles add column if not exists avatar_url text;
alter table public.programs add column if not exists image_url text;

-- 2) Pre-populate custom background config in app_config
insert into public.app_config (key, value)
values ('login_page_image_url', '/mosque_login.png')
on conflict (key) do nothing;
