-- 127_moderation_keywords.sql
-- v0.10.3 F201: Modération déterministe des commentaires par mots-clés (pas de ML)

CREATE TABLE IF NOT EXISTS public.moderation_keywords (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    word VARCHAR(50) NOT NULL,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    UNIQUE(word)
);

CREATE INDEX idx_moderation_keywords_word ON public.moderation_keywords(LOWER(word));

-- Seed initial minimal (spam, insultes basiques, langues FR/EN)
INSERT INTO public.moderation_keywords (word) VALUES
    ('spam'), ('scam'), ('virus'), ('free money'), ('click here'),
    ('casino'), ('lottery'), ('winner'), ('nigerian'), ('pharma'),
    ('viagra'), ('crypto'), ('bitcoin'), ('nft'), ('mlm')
ON CONFLICT (word) DO NOTHING;
