Skip to content

Commit 3ad8e2b

Browse files
committed
Change departmentId to int32 & add constraints
It was originally a str, so that leading zeros wouldn't cause formatting problems. But now that we require a specified funding account, there will never be leading zeros.
1 parent 4ae7f7f commit 3ad8e2b

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

dbschema/migrations/00034.edgeql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CREATE MIGRATION m1abuwgh5eb3m3ivtyo6lru3w6k7ermhoof3bphd72jtx2cezj7ewa
2+
ONTO m1ijgeabkfengfe2lpxjtq7xxqjiulhehay7tuutdoa5g3scsenwvq
3+
{
4+
ALTER TYPE default::Project {
5+
CREATE LINK fieldRegion: default::FieldRegion;
6+
CREATE LINK marketingLocation: default::Location;
7+
CREATE LINK primaryLocation: default::Location;
8+
CREATE TRIGGER enforceFundingAccount
9+
AFTER UPDATE
10+
FOR EACH DO (std::assert((std::any((__new__.primaryLocation.fundingAccount.accountNumber > 0)) OR NOT (EXISTS (__new__.primaryLocation))), message := 'Project must have a primary location with a specified funding account'));
11+
ALTER PROPERTY departmentId {
12+
SET TYPE std::int32 USING (<std::int32>.departmentId);
13+
};
14+
};
15+
};

dbschema/migrations/00035.edgeql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CREATE MIGRATION m13bndkbclxwviy3uj4eskx56bd2chw2xbvfn5pae557oslmbz2ssa
2+
ONTO m1abuwgh5eb3m3ivtyo6lru3w6k7ermhoof3bphd72jtx2cezj7ewa
3+
{
4+
ALTER TYPE default::Project {
5+
ALTER PROPERTY departmentId {
6+
CREATE CONSTRAINT std::exclusive;
7+
CREATE CONSTRAINT std::max_value(99999);
8+
CREATE CONSTRAINT std::min_value(10000);
9+
};
10+
};
11+
};

dbschema/project.esdl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ module default {
1010
default := Sensitivity.High;
1111
};
1212

13-
departmentId: str;
13+
departmentId: int32 {
14+
constraint exclusive;
15+
constraint min_value(10000);
16+
constraint max_value(99999);
17+
};
1418

1519
required step: Project::Step {
1620
default := Project::Step.EarlyConversations;

0 commit comments

Comments
 (0)