-- Add feedback_items table for Lyra Feedback-Loop feature
-- Users' feedback from coaching chat is auto-detected, stored here, and
-- Lyra proactively informs users when their idea status changes.

CREATE TYPE rebreak."FeedbackStatus" AS ENUM (
    'PENDING',
    'REVIEWING',
    'PLANNED',
    'SHIPPED',
    'REJECTED'
);

CREATE TABLE rebreak."feedback_items" (
    "id"         UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    "user_id"    UUID NOT NULL,
    "content"    TEXT NOT NULL,
    "category"   TEXT,
    "status"     rebreak."FeedbackStatus" NOT NULL DEFAULT 'PENDING',
    "admin_note" TEXT,
    "created_at" TIMESTAMPTZ NOT NULL DEFAULT now(),
    "updated_at" TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX "feedback_items_user_id_idx" ON rebreak."feedback_items" ("user_id");
CREATE INDEX "feedback_items_status_idx" ON rebreak."feedback_items" ("status");
