Skip to content

Commit 74f9f53

Browse files
atGit2021CarsonF
andauthored
[EdgeDB] ProgressReport.Child & VarianceExplanation schema (#3087)
Co-authored-by: Carson Full <[email protected]>
1 parent fc7a09f commit 74f9f53

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

dbschema/migrations/00055.edgeql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CREATE MIGRATION m13kr5hbnbuidyg3qtxulx7k53yqzb3sxcvacxryesnkgut3ntxtla
2+
ONTO m1mbjrsuqwwklgbswbvdbryp4p7gpgevkd7eq2qx6hfelhjvipkyhq
3+
{
4+
CREATE MODULE ProgressReport IF NOT EXISTS;
5+
CREATE ABSTRACT TYPE ProgressReport::Child EXTENDING Engagement::Child {
6+
CREATE ANNOTATION std::description := 'A type that is a child of a progress report. It will always have a reference to a single progress report and engagement that it is under.';
7+
CREATE REQUIRED LINK report: default::ProgressReport {
8+
ON TARGET DELETE DELETE SOURCE;
9+
SET readonly := true;
10+
};
11+
CREATE TRIGGER enforceProgressReportEngagement
12+
AFTER UPDATE, INSERT
13+
FOR EACH DO (std::assert((__new__.report.engagement = __new__.engagement), message := 'Given progress report must be for the same engagement as the given engagement'));
14+
};
15+
CREATE TYPE ProgressReport::VarianceExplanation EXTENDING ProgressReport::Child {
16+
ALTER LINK report {
17+
SET OWNED;
18+
CREATE CONSTRAINT std::exclusive;
19+
};
20+
CREATE PROPERTY comments: default::RichText;
21+
CREATE MULTI PROPERTY reasons: std::str;
22+
};
23+
ALTER TYPE default::ProgressReport {
24+
CREATE SINGLE LINK varianceExplanation := (.<report[IS ProgressReport::VarianceExplanation]);
25+
};
26+
};

dbschema/progress-report.esdl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,37 @@ module default {
22
type ProgressReport extending PeriodicReport, Engagement::Child {
33
overloaded container: LanguageEngagement;
44
overloaded engagement: LanguageEngagement;
5+
single varianceExplanation := .<report[is ProgressReport::VarianceExplanation];
6+
}
7+
}
8+
9+
module ProgressReport {
10+
abstract type Child extending Engagement::Child {
11+
annotation description := "\
12+
A type that is a child of a progress report. \
13+
14+
It will always have a reference to a single progress report and engagement that it is under.";
15+
16+
required report: default::ProgressReport {
17+
readonly := true;
18+
on target delete delete source;
19+
};
20+
21+
trigger enforceProgressReportEngagement after insert, update for each do (
22+
assert(
23+
__new__.report.engagement = __new__.engagement,
24+
message := "Given progress report must be for the same engagement as the given engagement"
25+
)
26+
);
27+
}
28+
29+
type VarianceExplanation extending ProgressReport::Child {
30+
overloaded report {
31+
constraint exclusive;
32+
};
33+
34+
multi reasons: str;
35+
36+
comments: default::RichText;
537
}
638
}

0 commit comments

Comments
 (0)