mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
committed by
GitHub
parent
161424601f
commit
59307e22bd
@@ -436,6 +436,23 @@ export async function createWorkflowRecord(params: CreateWorkflowInput) {
|
||||
const workflowId = crypto.randomUUID()
|
||||
const now = new Date()
|
||||
|
||||
const duplicateConditions = [
|
||||
eq(workflowTable.workspaceId, workspaceId),
|
||||
isNull(workflowTable.archivedAt),
|
||||
eq(workflowTable.name, name),
|
||||
...(folderId ? [eq(workflowTable.folderId, folderId)] : [isNull(workflowTable.folderId)]),
|
||||
]
|
||||
const [duplicateWorkflow] = await db
|
||||
.select({ id: workflowTable.id })
|
||||
.from(workflowTable)
|
||||
.where(and(...duplicateConditions))
|
||||
.limit(1)
|
||||
if (duplicateWorkflow) {
|
||||
throw new Error(
|
||||
`A workflow named "${name}" already exists in this folder. Use a different name.`
|
||||
)
|
||||
}
|
||||
|
||||
const workflowParentCondition = folderId
|
||||
? eq(workflowTable.folderId, folderId)
|
||||
: isNull(workflowTable.folderId)
|
||||
|
||||
Reference in New Issue
Block a user