We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d2187a4 commit f498c37Copy full SHA for f498c37
1 file changed
apps/sim/lib/logs/execution/snapshot/service.ts
@@ -120,7 +120,17 @@ export class SnapshotService implements ISnapshotService {
120
const ids = candidates.map((c) => c.id)
121
const deleted = await db
122
.delete(workflowExecutionSnapshots)
123
- .where(inArray(workflowExecutionSnapshots.id, ids))
+ .where(
124
+ and(
125
+ inArray(workflowExecutionSnapshots.id, ids),
126
+ notExists(
127
+ db
128
+ .select({ one: sql`1` })
129
+ .from(workflowExecutionLogs)
130
+ .where(eq(workflowExecutionLogs.stateSnapshotId, workflowExecutionSnapshots.id))
131
+ )
132
133
134
.returning({ id: workflowExecutionSnapshots.id })
135
136
totalDeleted += deleted.length
0 commit comments