unique quiz constraint

This commit is contained in:
Krispire Admin
2026-10-16 15:23:06 +05:30
parent b1f78b1655
commit eb02d08f14
6 changed files with 128 additions and 6 deletions
@@ -0,0 +1 @@
DROP INDEX IF EXISTS quizzes_one_per_target;
@@ -0,0 +1,6 @@
-- 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;