File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -436,6 +436,23 @@ export async function createWorkflowRecord(params: CreateWorkflowInput) {
436436 const workflowId = crypto . randomUUID ( )
437437 const now = new Date ( )
438438
439+ const duplicateConditions = [
440+ eq ( workflowTable . workspaceId , workspaceId ) ,
441+ isNull ( workflowTable . archivedAt ) ,
442+ eq ( workflowTable . name , name ) ,
443+ ...( folderId
444+ ? [ eq ( workflowTable . folderId , folderId ) ]
445+ : [ isNull ( workflowTable . folderId ) ] ) ,
446+ ]
447+ const [ duplicateWorkflow ] = await db
448+ . select ( { id : workflowTable . id } )
449+ . from ( workflowTable )
450+ . where ( and ( ...duplicateConditions ) )
451+ . limit ( 1 )
452+ if ( duplicateWorkflow ) {
453+ throw new Error ( `A workflow named "${ name } " already exists in this folder. Use a different name.` )
454+ }
455+
439456 const workflowParentCondition = folderId
440457 ? eq ( workflowTable . folderId , folderId )
441458 : isNull ( workflowTable . folderId )
You can’t perform that action at this time.
0 commit comments