Skip to content

Commit 7fe18d4

Browse files
committed
TaskScheduleInstance.projectId not nullable. Backfill in the migration
The backfill is for self-hosters, it will be a no-op for already filled rows (i.e. cloud)
1 parent 77cc952 commit 7fe18d4

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Warnings:
3+
4+
- Made the column `projectId` on table `TaskScheduleInstance` required. This step will fail if there are existing NULL values in that column.
5+
6+
*/
7+
-- Backfill from TaskSchedule
8+
UPDATE "TaskScheduleInstance" tsi
9+
SET
10+
"projectId" = ts."projectId"
11+
FROM
12+
"TaskSchedule" ts
13+
WHERE
14+
tsi."taskScheduleId" = ts."id"
15+
AND tsi."projectId" IS NULL;
16+
17+
-- AlterTable
18+
ALTER TABLE "public"."TaskScheduleInstance"
19+
ALTER COLUMN "projectId"
20+
SET
21+
NOT NULL;

internal-packages/database/prisma/schema.prisma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,8 +1946,8 @@ model TaskScheduleInstance {
19461946
environment RuntimeEnvironment @relation(fields: [environmentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
19471947
environmentId String
19481948
1949-
project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade, onUpdate: Cascade)
1950-
projectId String?
1949+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade, onUpdate: Cascade)
1950+
projectId String
19511951
19521952
createdAt DateTime @default(now())
19531953
updatedAt DateTime @updatedAt

0 commit comments

Comments
 (0)