-- 对话重命名表
CREATE TABLE IF NOT EXISTS conversation_names (
    id              UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    app_id          UUID NOT NULL,
    user_id         UUID NOT NULL,
    conversation_id TEXT NOT NULL,
    name            VARCHAR(100) NOT NULL,
    created_at      TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at      TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- 唯一约束：同一应用同一用户同一对话只能有一个名称
CREATE UNIQUE INDEX idx_conversation_names_unique
    ON conversation_names(app_id, user_id, conversation_id);
