Files
spsays-bff/migrations/0060_quiz_one_per_target.up.sql
2026-10-16 15:23:06 +05:30

7 lines
346 B
SQL

-- One quiz per piece of content. A chapter, lecture or conversation may carry
-- at most one live quiz; stand-alone quizzes (no path) are unlimited, and a
-- deleted quiz frees its link for a new one.
CREATE UNIQUE INDEX IF NOT EXISTS quizzes_one_per_target
ON quizzes (target_path)
WHERE deleted_at IS NULL AND target_path IS NOT NULL;