-- Extension 3: Family Calendar -- Multi-person family scheduling (single-user, no RLS) CREATE TABLE IF NOT EXISTS family_members ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), name TEXT NOT NULL, relationship TEXT, birth_date DATE, notes TEXT, created_at TIMESTAMPTZ NOT NULL DEFAULT now() ); CREATE TABLE IF NOT EXISTS activities ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), family_member_id UUID REFERENCES family_members(id) ON DELETE SET NULL, title TEXT NOT NULL, activity_type TEXT, day_of_week TEXT, start_time TIME, end_time TIME, start_date DATE, end_date DATE, location TEXT, notes TEXT, created_at TIMESTAMPTZ NOT NULL DEFAULT now() ); CREATE TABLE IF NOT EXISTS important_dates ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), family_member_id UUID REFERENCES family_members(id) ON DELETE SET NULL, title TEXT NOT NULL, date_value DATE NOT NULL, recurring_yearly BOOLEAN NOT NULL DEFAULT false, reminder_days_before INTEGER NOT NULL DEFAULT 7, notes TEXT, created_at TIMESTAMPTZ NOT NULL DEFAULT now() ); CREATE INDEX IF NOT EXISTS idx_activities_dow ON activities(day_of_week); CREATE INDEX IF NOT EXISTS idx_activities_member ON activities(family_member_id); CREATE INDEX IF NOT EXISTS idx_activities_dates ON activities(start_date, end_date); CREATE INDEX IF NOT EXISTS idx_important_dates_date ON important_dates(date_value);