diff --git a/dbschema/approver.gel b/dbschema/approver.gel new file mode 100644 index 0000000000..f35c6cbd1b --- /dev/null +++ b/dbschema/approver.gel @@ -0,0 +1,29 @@ +module Business { + scalar type `Group` extending enum< + Development, + FieldGrowth, + FieldOperations, + Finance, + MarketingCommunications, + OfficeOfThePresident, + People, + Technology, + > { + annotation description := "\ + Each group (formerly domain) within Seed Company. \ + OrganizationGroup was avoided to not be ambiguous with our Organizations here."; + } +} + +module Program { + type Approver { + annotation description := "\ + Certain users are approvers on behalf of their group for certain programs / project types."; + + required user: default::User { + constraint exclusive; + }; + required multi programs: Project::Type; + required multi groups: Business::Group; + } +} diff --git a/dbschema/migrations/00015-m16fwsg.edgeql b/dbschema/migrations/00015-m16fwsg.edgeql new file mode 100644 index 0000000000..a876e202a8 --- /dev/null +++ b/dbschema/migrations/00015-m16fwsg.edgeql @@ -0,0 +1,37 @@ +CREATE MIGRATION m16fwsgh2jrwv2pxyw3ej36uywbt7dhnyfankwp4sq3oqwtv2alydq + ONTO m1l7uuqm3my5klng3a2m6wqoswaq63h6jb63gvioafpj2t5yffxduq +{ + CREATE MODULE Business IF NOT EXISTS; + CREATE MODULE Program IF NOT EXISTS; + CREATE SCALAR TYPE Business::`Group` EXTENDING enum { + CREATE ANNOTATION std::description := 'Each group (formerly domain) within Seed Company. OrganizationGroup was avoided to not be ambiguous with our Organizations here.'; + }; + CREATE TYPE Program::Approver { + CREATE REQUIRED LINK user: default::User { + CREATE CONSTRAINT std::exclusive; + }; + CREATE REQUIRED MULTI PROPERTY groups: Business::`Group`; + CREATE REQUIRED MULTI PROPERTY programs: Project::Type; + CREATE ANNOTATION std::description := 'Certain users are approvers on behalf of their group for certain programs / project types.'; + }; + ALTER TYPE default::Project { + CREATE MULTI LINK approvers := (SELECT + Program::Approver + FILTER + (default::Project.type IN .programs) + ); + CREATE SINGLE LINK approver := (SELECT + .approvers FILTER + (.user = GLOBAL default::currentUser) + LIMIT + 1 + ); + }; + ALTER TYPE Project::ContextAware { + CREATE REQUIRED SINGLE PROPERTY isFinancialApprover := (EXISTS ((SELECT + .projectContext.projects.approver + FILTER + (Business::`Group`.Finance IN .groups) + ))); + }; +}; diff --git a/dbschema/project.gel b/dbschema/project.gel index 86ba87ffa2..dd0c67af02 100644 --- a/dbschema/project.gel +++ b/dbschema/project.gel @@ -80,7 +80,10 @@ module default { multi link members := .