Skip to content

Commit 1057cff

Browse files
committed
chore(db): remove unnecessary FK constraints on TaskRunExecutionSnapshot
1 parent 28f8cee commit 1057cff

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
@@ -209,7 +209,6 @@ model Organization {
209209
organizationAccessTokens OrganizationAccessToken[]
210210
workerGroups WorkerInstanceGroup[]
211211
workerInstances WorkerInstance[]
212-
executionSnapshots TaskRunExecutionSnapshot[]
213212
githubAppInstallations GithubAppInstallation[]
214213
}
215214

@@ -326,7 +325,6 @@ model RuntimeEnvironment {
326325
taskRunCheckpoints TaskRunCheckpoint[]
327326
waitpoints Waitpoint[]
328327
workerInstances WorkerInstance[]
329-
executionSnapshots TaskRunExecutionSnapshot[]
330328
waitpointTags WaitpointTag[]
331329
BulkActionGroup BulkActionGroup[]
332330
@@ -391,7 +389,6 @@ model Project {
391389
waitpoints Waitpoint[]
392390
taskRunWaitpoints TaskRunWaitpoint[]
393391
taskRunCheckpoints TaskRunCheckpoint[]
394-
executionSnapshots TaskRunExecutionSnapshot[]
395392
waitpointTags WaitpointTag[]
396393
connectedGithubRepository ConnectedGithubRepository?
397394
@@ -898,21 +895,15 @@ model TaskRunExecutionSnapshot {
898895
899896
// Batch
900897
batchId String?
901-
batch BatchTaskRun? @relation(fields: [batchId], references: [id])
902898
903899
/// This is the current run attempt number. Users can define how many attempts they want for a run.
904900
attemptNumber Int?
905901
906902
/// Environment
907903
environmentId String
908-
environment RuntimeEnvironment @relation(fields: [environmentId], references: [id])
909904
environmentType RuntimeEnvironmentType
910-
911-
projectId String
912-
project Project @relation(fields: [projectId], references: [id])
913-
914-
organizationId String
915-
organization Organization @relation(fields: [organizationId], references: [id])
905+
projectId String
906+
organizationId String
916907
917908
/// Waitpoints that have been completed for this execution
918909
completedWaitpoints Waitpoint[] @relation("completedWaitpoints")
@@ -926,8 +917,6 @@ model TaskRunExecutionSnapshot {
926917
927918
/// Worker
928919
workerId String?
929-
worker WorkerInstance? @relation(fields: [workerId], references: [id])
930-
931920
runnerId String?
932921
933922
createdAt DateTime @default(now())
@@ -1149,8 +1138,6 @@ model WorkerInstance {
11491138
workerGroup WorkerInstanceGroup @relation(fields: [workerGroupId], references: [id])
11501139
workerGroupId String
11511140
1152-
TaskRunExecutionSnapshot TaskRunExecutionSnapshot[]
1153-
11541141
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
11551142
organizationId String?
11561143
@@ -1541,13 +1528,11 @@ model BatchTaskRun {
15411528
batchVersion String @default("v1")
15421529
15431530
//engine v2
1544-
/// Snapshots that reference this batch
1545-
executionSnapshots TaskRunExecutionSnapshot[]
15461531
/// Specific run blockers,
1547-
runsBlocked TaskRunWaitpoint[]
1532+
runsBlocked TaskRunWaitpoint[]
15481533
/// Waitpoints that are blocked by this batch.
15491534
/// When a Batch is created it blocks execution of the associated parent run (for andWait)
1550-
waitpoints Waitpoint[]
1535+
waitpoints Waitpoint[]
15511536
15521537
// This is for v3 batches
15531538
/// 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
@@ -374,12 +374,10 @@ export class ExecutionSnapshotSystem {
374374
});
375375
}
376376

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

385383
//extending the heartbeat

0 commit comments

Comments
 (0)