Skip to content

Commit fa2a9f7

Browse files
committed
feat(database): add defaultWorkerGroupId to RuntimeEnvironment
Adds a nullable FK for per-environment default region selection. Resolution will fall back to the project default, then the global default.
1 parent 1b0f2c7 commit fa2a9f7

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- AlterTable
2+
ALTER TABLE "public"."RuntimeEnvironment" ADD COLUMN "defaultWorkerGroupId" TEXT;
3+
4+
-- AddForeignKey
5+
ALTER TABLE "public"."RuntimeEnvironment" ADD CONSTRAINT "RuntimeEnvironment_defaultWorkerGroupId_fkey" FOREIGN KEY ("defaultWorkerGroupId") REFERENCES "public"."WorkerInstanceGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE;

internal-packages/database/prisma/schema.prisma

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ model RuntimeEnvironment {
354354
orgMember OrgMember? @relation(fields: [orgMemberId], references: [id], onDelete: SetNull, onUpdate: Cascade)
355355
orgMemberId String?
356356
357+
/// The default region for this environment. Falls back to the project default, then the global default.
358+
defaultWorkerGroup WorkerInstanceGroup? @relation("EnvironmentDefaultWorkerGroup", fields: [defaultWorkerGroupId], references: [id])
359+
defaultWorkerGroupId String?
360+
357361
createdAt DateTime @default(now())
358362
updatedAt DateTime @updatedAt
359363
@@ -1517,7 +1521,8 @@ model WorkerInstanceGroup {
15171521
workers WorkerInstance[]
15181522
backgroundWorkers BackgroundWorker[]
15191523
1520-
defaultForProjects Project[] @relation("ProjectDefaultWorkerGroup")
1524+
defaultForProjects Project[] @relation("ProjectDefaultWorkerGroup")
1525+
defaultForEnvironments RuntimeEnvironment[] @relation("EnvironmentDefaultWorkerGroup")
15211526
15221527
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
15231528
organizationId String?

0 commit comments

Comments
 (0)