(params: {
workflowId: string
deploymentVersionId: string
blocks: Record<string, BlockState>
})
| 574 | } |
| 575 | |
| 576 | async function createSchedulesIfStillActive(params: { |
| 577 | workflowId: string |
| 578 | deploymentVersionId: string |
| 579 | blocks: Record<string, BlockState> |
| 580 | }) { |
| 581 | return db.transaction(async (tx) => { |
| 582 | const [workflowRecord] = await tx |
| 583 | .select({ id: workflowTable.id }) |
| 584 | .from(workflowTable) |
| 585 | .where(eq(workflowTable.id, params.workflowId)) |
| 586 | .limit(1) |
| 587 | .for('update') |
| 588 | |
| 589 | if (!workflowRecord) { |
| 590 | return { success: true as const } |
| 591 | } |
| 592 | |
| 593 | const [versionRow] = await tx |
| 594 | .select({ id: workflowDeploymentVersion.id }) |
| 595 | .from(workflowDeploymentVersion) |
| 596 | .where( |
| 597 | and( |
| 598 | eq(workflowDeploymentVersion.workflowId, params.workflowId), |
| 599 | eq(workflowDeploymentVersion.id, params.deploymentVersionId), |
| 600 | eq(workflowDeploymentVersion.isActive, true) |
| 601 | ) |
| 602 | ) |
| 603 | .limit(1) |
| 604 | |
| 605 | if (!versionRow) { |
| 606 | return { success: true as const } |
| 607 | } |
| 608 | |
| 609 | const result = await createSchedulesForDeploy( |
| 610 | params.workflowId, |
| 611 | params.blocks, |
| 612 | tx, |
| 613 | params.deploymentVersionId |
| 614 | ) |
| 615 | if (!result.success) { |
| 616 | throw new Error(result.error || 'Failed to sync schedules') |
| 617 | } |
| 618 | return result |
| 619 | }) |
| 620 | } |
| 621 | |
| 622 | async function pruneWorkflowGroupOutputsIfStillActive(params: { |
| 623 | workflowId: string |
no test coverage detected