Skip to content

Commit d4c7e57

Browse files
bryanjnelsonCarsonF
authored andcommitted
Add trigger assertions for firstScripture in Engagement schema
1 parent ed0696f commit d4c7e57

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

dbschema/engagement.esdl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,20 @@ module default {
5151
property firstScripture := (
5252
exists .language.firstScriptureEngagement
5353
);
54-
54+
55+
trigger denyDuplicateFirstScriptureBasedOnExternal after insert, update for each do (
56+
assert(
57+
not __new__.firstScripture or not exists __new__.language.hasExternalFirstScripture,
58+
message := "First scripture has already been marked as having been done externally"
59+
)
60+
);
61+
trigger denyDuplicateFirstScriptureBasedOnOtherEngagement after insert, update for each do (
62+
assert(
63+
not exists (select __new__.language.engagements filter .firstScripture),
64+
message := "Another engagement has already been marked as having done the first scripture"
65+
)
66+
);
67+
5568
required lukePartnership: bool {
5669
default := false;
5770
};

0 commit comments

Comments
 (0)