Skip to content

Commit a3fd1c2

Browse files
committed
Add startedAt to the deployment schema
1 parent 0f6b0f1 commit a3fd1c2

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

apps/webapp/app/v3/services/deployment.server.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { type AuthenticatedEnvironment } from "~/services/apiAuth.server";
22
import { BaseService } from "./baseService.server";
33
import { errAsync, fromPromise, okAsync } from "neverthrow";
44
import { type WorkerDeploymentStatus, type WorkerDeployment } from "@trigger.dev/database";
5-
import { type GitMeta } from "@trigger.dev/core/v3";
5+
import { logger, type GitMeta } from "@trigger.dev/core/v3";
66
import { TimeoutDeploymentService } from "./timeoutDeployment.server";
77
import { env } from "~/env.server";
88

@@ -37,6 +37,9 @@ export class DeploymentService extends BaseService {
3737

3838
const validateDeployment = (deployment: Pick<WorkerDeployment, "id" | "status">) => {
3939
if (deployment.status !== "PENDING") {
40+
logger.warn("Attempted starting deployment that is not in PENDING status", {
41+
deployment,
42+
});
4043
return errAsync({ type: "deployment_not_pending" as const });
4144
}
4245

@@ -47,7 +50,7 @@ export class DeploymentService extends BaseService {
4750
fromPromise(
4851
this._prisma.workerDeployment.updateMany({
4952
where: { id: deployment.id, status: "PENDING" }, // status could've changed in the meantime, we're not locking the row
50-
data: { ...updates, status: "BUILDING" },
53+
data: { ...updates, status: "BUILDING", startedAt: new Date() },
5154
}),
5255
(error) => ({
5356
type: "other" as const,

apps/webapp/app/v3/services/initializeDeployment.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export class InitializeDeploymentService extends BaseService {
131131
imagePlatform: env.DEPLOY_IMAGE_PLATFORM,
132132
git: payload.gitMeta ?? undefined,
133133
runtime: payload.runtime ?? undefined,
134+
startedAt: initialStatus === "BUILDING" ? new Date() : undefined,
134135
},
135136
});
136137

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "public"."WorkerDeployment" ADD COLUMN "startedAt" TIMESTAMP(3);

internal-packages/database/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,7 @@ model WorkerDeployment {
17641764
triggeredBy User? @relation(fields: [triggeredById], references: [id], onDelete: SetNull, onUpdate: Cascade)
17651765
triggeredById String?
17661766
1767+
startedAt DateTime?
17671768
builtAt DateTime?
17681769
deployedAt DateTime?
17691770

0 commit comments

Comments
 (0)