11import { db } from '@sim/db'
2- import { pausedExecutions , permissions , workflow , workflowExecutionLogs } from '@sim/db/schema'
2+ import {
3+ pausedExecutions ,
4+ permissions ,
5+ workflow ,
6+ workflowDeploymentVersion ,
7+ workflowExecutionLogs ,
8+ } from '@sim/db/schema'
39import { and , desc , eq , gte , inArray , isNotNull , isNull , lte , or , type SQL , sql } from 'drizzle-orm'
410import { type NextRequest , NextResponse } from 'next/server'
511import { z } from 'zod'
@@ -51,6 +57,7 @@ export async function GET(request: NextRequest) {
5157 workflowId : workflowExecutionLogs . workflowId ,
5258 executionId : workflowExecutionLogs . executionId ,
5359 stateSnapshotId : workflowExecutionLogs . stateSnapshotId ,
60+ deploymentVersionId : workflowExecutionLogs . deploymentVersionId ,
5461 level : workflowExecutionLogs . level ,
5562 trigger : workflowExecutionLogs . trigger ,
5663 startedAt : workflowExecutionLogs . startedAt ,
@@ -71,13 +78,16 @@ export async function GET(request: NextRequest) {
7178 pausedStatus : pausedExecutions . status ,
7279 pausedTotalPauseCount : pausedExecutions . totalPauseCount ,
7380 pausedResumedCount : pausedExecutions . resumedCount ,
81+ deploymentVersion : workflowDeploymentVersion . version ,
82+ deploymentVersionName : workflowDeploymentVersion . name ,
7483 }
7584 : {
7685 // Basic mode - exclude large fields for better performance
7786 id : workflowExecutionLogs . id ,
7887 workflowId : workflowExecutionLogs . workflowId ,
7988 executionId : workflowExecutionLogs . executionId ,
8089 stateSnapshotId : workflowExecutionLogs . stateSnapshotId ,
90+ deploymentVersionId : workflowExecutionLogs . deploymentVersionId ,
8191 level : workflowExecutionLogs . level ,
8292 trigger : workflowExecutionLogs . trigger ,
8393 startedAt : workflowExecutionLogs . startedAt ,
@@ -98,6 +108,8 @@ export async function GET(request: NextRequest) {
98108 pausedStatus : pausedExecutions . status ,
99109 pausedTotalPauseCount : pausedExecutions . totalPauseCount ,
100110 pausedResumedCount : pausedExecutions . resumedCount ,
111+ deploymentVersion : workflowDeploymentVersion . version ,
112+ deploymentVersionName : sql < null > `NULL` , // Only needed in full mode for details panel
101113 }
102114
103115 const baseQuery = db
@@ -107,6 +119,10 @@ export async function GET(request: NextRequest) {
107119 pausedExecutions ,
108120 eq ( pausedExecutions . executionId , workflowExecutionLogs . executionId )
109121 )
122+ . leftJoin (
123+ workflowDeploymentVersion ,
124+ eq ( workflowDeploymentVersion . id , workflowExecutionLogs . deploymentVersionId )
125+ )
110126 . innerJoin (
111127 workflow ,
112128 and (
@@ -397,6 +413,9 @@ export async function GET(request: NextRequest) {
397413 id : log . id ,
398414 workflowId : log . workflowId ,
399415 executionId : log . executionId ,
416+ deploymentVersionId : log . deploymentVersionId ,
417+ deploymentVersion : log . deploymentVersion ?? null ,
418+ deploymentVersionName : log . deploymentVersionName ?? null ,
400419 level : log . level ,
401420 duration : log . totalDurationMs ? `${ log . totalDurationMs } ms` : null ,
402421 trigger : log . trigger ,
0 commit comments