fix(education): reject public collection inserts

This commit is contained in:
2026-07-31 11:24:26 +08:00
parent b531be0d5b
commit bc2d555eb3

View File

@@ -97,8 +97,7 @@ BEGIN
IF TG_OP='INSERT' THEN
IF NEW.deleted THEN RAISE EXCEPTION 'collection cannot start deleted' USING ERRCODE='23514'; END IF;
IF NEW.scope='PUBLIC' THEN
IF NEW.publication_status<>'ACTIVE' OR NOT NEW.is_active OR NEW.is_hidden OR NEW.authoring_version<>0 THEN
RAISE EXCEPTION 'PUBLIC collection writes are not tenant authoring' USING ERRCODE='23514'; END IF;
RAISE EXCEPTION 'PUBLIC collection writes are not tenant authoring' USING ERRCODE='23514';
ELSIF NEW.scope='TENANT_OWNED' THEN
IF NEW.collection_type<>'MANUAL' OR NEW.publication_status<>'DRAFT' OR NEW.is_active OR NOT NEW.is_hidden OR NEW.authoring_version<>0 OR NEW.membership_version<>0 OR NEW.question_count<>0 THEN
RAISE EXCEPTION 'tenant collection must start empty DRAFT' USING ERRCODE='23514';