File tree Expand file tree Collapse file tree 2 files changed +47
-22
lines changed Expand file tree Collapse file tree 2 files changed +47
-22
lines changed Original file line number Diff line number Diff line change
1
+ CREATE MIGRATION m1tn7o5vizqaygjvghqysxzw6ruf4xohudb2usgfg4z622ens24mba
2
+ ONTO m1ah6i4a5c6enkrmypo7k3y6f3flr26mqlqtkw2t6437evoxqqzpna
3
+ {
4
+ ALTER TYPE default :: Project {
5
+ ALTER PROPERTY departmentId {
6
+ CREATE REWRITE
7
+ UPDATE
8
+ USING ((IF ((NOT (EXISTS (.departmentId)) AND (.status <= Project:: Status.Active)) AND (.step >= Project:: Step.PendingFinanceConfirmation)) THEN (WITH
9
+ fa :=
10
+ std :: assert_exists (__subject__ .primaryLocation.fundingAccount, message := ' Project must have a primary location' )
11
+ ,
12
+ existing :=
13
+ (SELECT
14
+ (DETACHED default :: Project).departmentId
15
+ FILTER
16
+ (default :: Project.primaryLocation.fundingAccount = fa)
17
+ )
18
+ ,
19
+ available :=
20
+ (std :: range_unpack (std :: range (((fa.accountNumber * 10000 ) + 11 ), ((fa.accountNumber * 10000 ) + 9999 ))) EXCEPT existing)
21
+ SELECT
22
+ std :: min (available)
23
+ ) ELSE .departmentId));
24
+ };
25
+ };
26
+ };
Original file line number Diff line number Diff line change @@ -13,28 +13,27 @@ module default {
13
13
departmentId: int32 {
14
14
constraint exclusive ;
15
15
constraint expression on (__subject__ >= 10000 and __subject__ <= 99999 );
16
- # Temporarily disabled. Upstream fix in progress.
17
- # rewrite update using (
18
- # if (
19
- # not exists .departmentId and
20
- # .status <= Project::Status.Active and
21
- # .step >= Project::Step.PendingFinanceConfirmation
22
- # ) then ((
23
- # with
24
- # fa := assert_exists(
25
- # __subject__.primaryLocation.fundingAccount,
26
- # message := "Project must have a primary location"
27
- # ),
28
- # existing := (
29
- # select detached Project.departmentId filter Project.primaryLocation.fundingAccount = fa
30
- # ),
31
- # available := (
32
- # range_unpack(range(fa.accountNumber * 10000 + 11, fa.accountNumber * 10000 + 9999))
33
- # except existing
34
- # )
35
- # select min(available)
36
- # )) else .departmentId
37
- # );
16
+ rewrite update using (
17
+ if (
18
+ not exists .departmentId and
19
+ .status <= Project:: Status.Active and
20
+ .step >= Project:: Step.PendingFinanceConfirmation
21
+ ) then ((
22
+ with
23
+ fa := assert_exists (
24
+ __subject__ .primaryLocation.fundingAccount,
25
+ message := " Project must have a primary location"
26
+ ),
27
+ existing := (
28
+ select detached Project.departmentId filter Project.primaryLocation.fundingAccount = fa
29
+ ),
30
+ available := (
31
+ range_unpack (range (fa.accountNumber * 10000 + 11 , fa.accountNumber * 10000 + 9999 ))
32
+ except existing
33
+ )
34
+ select min (available)
35
+ )) else .departmentId
36
+ );
38
37
};
39
38
40
39
required step: Project:: Step {
You can’t perform that action at this time.
0 commit comments