File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 11import { RunEngineVersion , RuntimeEnvironmentType } from "@trigger.dev/database" ;
22import { AuthenticatedEnvironment } from "~/services/apiAuth.server" ;
3+ import { findCurrentWorkerDeploymentWithoutTasks } from "./models/workerDeployment.server" ;
34
45export async function determineEngineVersion ( {
56 environment,
@@ -8,7 +9,9 @@ export async function determineEngineVersion({
89 environment : AuthenticatedEnvironment ;
910 version ?: RunEngineVersion ;
1011} ) : Promise < RunEngineVersion > {
11- if ( version ) return version ;
12+ if ( version ) {
13+ return version ;
14+ }
1215
1316 // If the project is V1, then none of the background workers are running V2
1417 if ( environment . project . engine === RunEngineVersion . V1 ) {
@@ -20,6 +23,16 @@ export async function determineEngineVersion({
2023 return "V1" ;
2124 }
2225
26+ /**
27+ * The project has V2 enabled and this isn't dev
28+ */
29+
30+ // Check the current deployment for this environment
31+ const currentDeployment = await findCurrentWorkerDeploymentWithoutTasks ( environment . id ) ;
32+ if ( currentDeployment ?. type === "V1" ) {
33+ return "V1" ;
34+ }
35+
2336 //todo we need to determine the version using the BackgroundWorker
2437 //- triggerAndWait we can lookup the BackgroundWorker easily, and get the engine.
2538 //- No locked version: lookup the BackgroundWorker via the Deployment/latest dev BW
Original file line number Diff line number Diff line change 11import type { Prettify } from "@trigger.dev/core" ;
2- import { BackgroundWorker } from "@trigger.dev/database" ;
2+ import { BackgroundWorker , WorkerDeployment } from "@trigger.dev/database" ;
33import { CURRENT_DEPLOYMENT_LABEL , CURRENT_UNMANAGED_DEPLOYMENT_LABEL } from "~/consts" ;
44import { Prisma , prisma } from "~/db.server" ;
55import { AuthenticatedEnvironment } from "~/services/apiAuth.server" ;
@@ -45,6 +45,25 @@ export async function findCurrentWorkerDeployment(
4545 return promotion ?. deployment ;
4646}
4747
48+ export async function findCurrentWorkerDeploymentWithoutTasks (
49+ environmentId : string ,
50+ label = CURRENT_DEPLOYMENT_LABEL
51+ ) : Promise < WorkerDeployment | undefined > {
52+ const promotion = await prisma . workerDeploymentPromotion . findUnique ( {
53+ where : {
54+ environmentId_label : {
55+ environmentId,
56+ label,
57+ } ,
58+ } ,
59+ include : {
60+ deployment : true ,
61+ } ,
62+ } ) ;
63+
64+ return promotion ?. deployment ;
65+ }
66+
4867export async function findCurrentUnmanagedWorkerDeployment (
4968 environmentId : string
5069) : Promise < WorkerDeploymentWithWorkerTasks | undefined > {
You can’t perform that action at this time.
0 commit comments