-- Create the syntheses table for storing generated news syntheses.

CREATE TABLE syntheses (
    id          UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id     UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    week        VARCHAR(10) NOT NULL,
    sections    JSONB NOT NULL DEFAULT '[]'::jsonb,
    status      VARCHAR(20) NOT NULL DEFAULT 'completed',
    created_at  TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX idx_syntheses_user_id_created_at ON syntheses(user_id, created_at DESC);
