Skip to content

Commit

Permalink
[EdgeDB] Add some constraints for project's own context (#2932)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF authored Nov 10, 2023
1 parent ac6332b commit fe124b4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dbschema/project.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ module default {
overloaded link projectContext: Project::Context {
default := (insert Project::Context);
}
# Setting the new project as its own context should be the immediate next thing that happens
# So enforce that that happens (as best we can), and assert that the context is ever only itself.
trigger enforceContext after update for each do (
assert(
__new__ in __new__.projectContext.projects and count(__new__.projectContext.projects) = 1,
message := "A Project's own context should be itself (no more or less)"
)
);
}

type TranslationProject extending Project {
Expand Down

0 comments on commit fe124b4

Please sign in to comment.