-- ============================================================
-- Cielo — Coordinator character Supabase setup
-- Run this once in the Supabase SQL editor
-- ============================================================

-- Recommendations table: stores every character suggestion Cielo made
CREATE TABLE IF NOT EXISTS cielo_recommendations (
    id                    UUID DEFAULT gen_random_uuid() PRIMARY KEY,
    user_id               TEXT NOT NULL,
    user_message          TEXT,
    recommended_character TEXT NOT NULL,
    reason                TEXT,
    created_at            TIMESTAMPTZ DEFAULT now()
);

CREATE INDEX IF NOT EXISTS idx_cielo_recommendations_user_id
    ON cielo_recommendations (user_id);

ALTER TABLE cielo_recommendations ENABLE ROW LEVEL SECURITY;

CREATE POLICY "service_role_all_cielo" ON cielo_recommendations
    FOR ALL TO service_role USING (true) WITH CHECK (true);
