Skip to content

Commit f8977a7

Browse files
authored
chore(db): remove unnecessary FK constraints on TaskRunExecutionSnapshot (#2533)
1 parent f0643f7 commit f8977a7

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- DropForeignKey
2+
ALTER TABLE "public"."TaskRunExecutionSnapshot" DROP CONSTRAINT IF EXISTS "TaskRunExecutionSnapshot_batchId_fkey";
3+
4+
-- DropForeignKey
5+
ALTER TABLE "public"."TaskRunExecutionSnapshot" DROP CONSTRAINT IF EXISTS "TaskRunExecutionSnapshot_environmentId_fkey";
6+
7+
-- DropForeignKey
8+
ALTER TABLE "public"."TaskRunExecutionSnapshot" DROP CONSTRAINT IF EXISTS "TaskRunExecutionSnapshot_organizationId_fkey";
9+
10+
-- DropForeignKey
11+
ALTER TABLE "public"."TaskRunExecutionSnapshot" DROP CONSTRAINT IF EXISTS "TaskRunExecutionSnapshot_projectId_fkey";
12+
13+
-- DropForeignKey
14+
ALTER TABLE "public"."TaskRunExecutionSnapshot" DROP CONSTRAINT IF EXISTS "TaskRunExecutionSnapshot_workerId_fkey";

internal-packages/database/prisma/schema.prisma

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ model Organization {
211211
organizationAccessTokens OrganizationAccessToken[]
212212
workerGroups WorkerInstanceGroup[]
213213
workerInstances WorkerInstance[]
214-
executionSnapshots TaskRunExecutionSnapshot[]
215214
githubAppInstallations GithubAppInstallation[]
216215
}
217216

@@ -328,7 +327,6 @@ model RuntimeEnvironment {
328327
taskRunCheckpoints TaskRunCheckpoint[]
329328
waitpoints Waitpoint[]
330329
workerInstances WorkerInstance[]
331-
executionSnapshots TaskRunExecutionSnapshot[]
332330
waitpointTags WaitpointTag[]
333331
BulkActionGroup BulkActionGroup[]
334332
@@ -393,7 +391,6 @@ model Project {
393391
waitpoints Waitpoint[]
394392
taskRunWaitpoints TaskRunWaitpoint[]
395393
taskRunCheckpoints TaskRunCheckpoint[]
396-
executionSnapshots TaskRunExecutionSnapshot[]
397394
waitpointTags WaitpointTag[]
398395
connectedGithubRepository ConnectedGithubRepository?
399396
@@ -900,21 +897,15 @@ model TaskRunExecutionSnapshot {
900897
901898
// Batch
902899
batchId String?
903-
batch BatchTaskRun? @relation(fields: [batchId], references: [id])
904900
905901
/// This is the current run attempt number. Users can define how many attempts they want for a run.
906902
attemptNumber Int?
907903
908904
/// Environment
909905
environmentId String
910-
environment RuntimeEnvironment @relation(fields: [environmentId], references: [id])
911906
environmentType RuntimeEnvironmentType
912-
913-
projectId String
914-
project Project @relation(fields: [projectId], references: [id])
915-
916-
organizationId String
917-
organization Organization @relation(fields: [organizationId], references: [id])
907+
projectId String
908+
organizationId String
918909
919910
/// Waitpoints that have been completed for this execution
920911
completedWaitpoints Waitpoint[] @relation("completedWaitpoints")
@@ -928,8 +919,6 @@ model TaskRunExecutionSnapshot {
928919
929920
/// Worker
930921
workerId String?
931-
worker WorkerInstance? @relation(fields: [workerId], references: [id])
932-
933922
runnerId String?
934923
935924
createdAt DateTime @default(now())
@@ -1151,8 +1140,6 @@ model WorkerInstance {
11511140
workerGroup WorkerInstanceGroup @relation(fields: [workerGroupId], references: [id])
11521141
workerGroupId String
11531142
1154-
TaskRunExecutionSnapshot TaskRunExecutionSnapshot[]
1155-
11561143
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
11571144
organizationId String?
11581145
@@ -1543,13 +1530,11 @@ model BatchTaskRun {
15431530
batchVersion String @default("v1")
15441531
15451532
//engine v2
1546-
/// Snapshots that reference this batch
1547-
executionSnapshots TaskRunExecutionSnapshot[]
15481533
/// Specific run blockers,
1549-
runsBlocked TaskRunWaitpoint[]
1534+
runsBlocked TaskRunWaitpoint[]
15501535
/// Waitpoints that are blocked by this batch.
15511536
/// When a Batch is created it blocks execution of the associated parent run (for andWait)
1552-
waitpoints Waitpoint[]
1537+
waitpoints Waitpoint[]
15531538
15541539
// This is for v3 batches
15551540
/// sealed is set to true once no more items can be added to the batch

internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,10 @@ export class ExecutionSnapshotSystem {
375375
});
376376
}
377377

378-
//update the snapshot heartbeat time
379-
await prisma.taskRunExecutionSnapshot.update({
380-
where: { id: latestSnapshot.id },
381-
data: {
382-
lastHeartbeatAt: new Date(),
383-
},
378+
this.$.logger.info("heartbeatRun snapshot heartbeat updated", {
379+
id: latestSnapshot.id,
380+
runId: latestSnapshot.runId,
381+
lastHeartbeatAt: new Date(),
384382
});
385383

386384
//extending the heartbeat

0 commit comments

Comments
 (0)