CREATE UNIQUE INDEX prompts_repository_user_state_idx
    ON prompts (repository_id, gitea_user_id, state_id)
    WHERE gitea_user_id IS NOT NULL AND state_id <> '';
