diff --git a/Dockerfile b/Dockerfile index 67a72bd7a2..82b59d4ce7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG NODE_VERSION=22 ARG NODE_IMAGE=public.ecr.aws/docker/library/node:${NODE_VERSION}-slim -ARG GEL_IMAGE=ghcr.io/geldata/gel:6.4 +ARG GEL_IMAGE=ghcr.io/geldata/gel:6.8 FROM ${NODE_IMAGE} AS base-runtime diff --git a/dbschema/migrations/00023-m1gur4j.edgeql b/dbschema/migrations/00023-m1gur4j.edgeql new file mode 100644 index 0000000000..c5a1ad7aad --- /dev/null +++ b/dbschema/migrations/00023-m1gur4j.edgeql @@ -0,0 +1,30 @@ +CREATE MIGRATION m1rgcov4cvwz6cct475bg4236373bwpc4piydlw5ytakm5fyn7g2eq + ONTO m1xp5mbrgbcsdkvhimirvlj2hueu7m7aeyowjcp3wl4itrzityln4q +{ + ALTER TYPE default::Project { + CREATE LINK primaryPartnership := ( + select Partnership + filter Partnership.primary and Partnership.project = __source__ + limit 1 + ); + ALTER PROPERTY departmentId { + DROP REWRITE INSERT, UPDATE; + CREATE REWRITE INSERT, UPDATE USING (( + IF ( + (NOT (EXISTS (.departmentId)) + AND (.status <= Project::Status.Active)) + AND (.step >= Project::Step.PendingFinanceConfirmation) + ) THEN ( + WITH block := ( + IF (__subject__ IS default::MultiplicationTranslationProject) + THEN ( + WITH primaryPartnership := std::assert_exists(__subject__.primaryPartnership, message := 'Project must have a primary partnership'), + SELECT std::assert_exists(primaryPartnership.partner.departmentIdBlock, message := 'Available Department IDs have not been declared') + ) + ELSE (std::assert_exists((std::assert_exists(__subject__.primaryLocation, message := 'Project must have a primary location')).fundingAccount, message := "Project's primary location must have a funding account")).departmentIdBlock) + SELECT std::assert_exists(block.nextAvailable, message := 'No department ID is available') + ) ELSE .departmentId + )); + }; + }; +}; diff --git a/dbschema/project.gel b/dbschema/project.gel index 37de95d5d2..cf5c8abf3f 100644 --- a/dbschema/project.gel +++ b/dbschema/project.gel @@ -30,15 +30,16 @@ module default { .step >= Project::Step.PendingFinanceConfirmation ) then (( with block := ( - if __subject__ is MultiplicationTranslationProject then ( - assert_exists( - assert_exists( - (select __subject__.partnerships filter .primary).partner, - message := "Project must have a primary partnership" - ).departmentIdBlock, + if __subject__ is MultiplicationTranslationProject then (( + with primaryPartnership := assert_exists( + __subject__.primaryPartnership, + message := "Project must have a primary partnership" + ) + select assert_exists( + primaryPartnership.partner.departmentIdBlock, message := "Available Department IDs have not been declared" ) - ) else ( + )) else ( assert_exists( assert_exists( __subject__.primaryLocation, @@ -102,6 +103,13 @@ module default { link rootDirectory: Directory; partnerships := .