@@ -38,7 +38,6 @@ import { generateRestoreName } from '@/lib/core/utils/restore-name'
3838import type { DbOrTx } from '@/lib/db/types'
3939import { materializeExecutionData } from '@/lib/logs/execution/trace-store'
4040import {
41- collectColumnIds ,
4241 columnMatchesRef ,
4342 generateColumnId ,
4443 getColumnId ,
@@ -585,7 +584,7 @@ export async function addTableColumn(
585584 const newColumn : TableSchema [ 'columns' ] [ number ] = {
586585 // Honor a caller-provided id (undo of a delete reuses the original id);
587586 // otherwise mint a fresh one.
588- id : column . id ?? generateColumnId ( collectColumnIds ( schema ) ) ,
587+ id : column . id ?? generateColumnId ( ) ,
589588 name : column . name ,
590589 type : column . type as TableSchema [ 'columns' ] [ number ] [ 'type' ] ,
591590 required : column . required ?? false ,
@@ -662,7 +661,6 @@ export async function addTableColumnsWithTx(
662661 if ( columns . length === 0 ) return table
663662
664663 const usedNames = new Set ( table . schema . columns . map ( ( c ) => c . name . toLowerCase ( ) ) )
665- const takenIds = new Set ( collectColumnIds ( table . schema ) )
666664 const additions : TableSchema [ 'columns' ] = [ ]
667665
668666 for ( const column of columns ) {
@@ -688,8 +686,7 @@ export async function addTableColumnsWithTx(
688686 usedNames . add ( lower )
689687 // Honor a caller-assigned id (the CSV append path pre-assigns so coercion
690688 // and persistence agree); otherwise mint one.
691- const id = column . id ?? generateColumnId ( takenIds )
692- takenIds . add ( id )
689+ const id = column . id ?? generateColumnId ( )
693690 additions . push ( {
694691 id,
695692 name : column . name ,
@@ -3932,13 +3929,9 @@ export async function addWorkflowGroup(
39323929 // Assign stable ids to the new output columns, then rewrite the group's
39333930 // column refs from name → id so outputs/deps/inputMappings key on ids —
39343931 // matching the row-data storage key and surviving future renames.
3935- const takenIds = new Set ( collectColumnIds ( schema ) )
3936- const outputColumns = data . outputColumns . map ( ( col ) => {
3937- if ( col . id ) return col
3938- const id = generateColumnId ( takenIds )
3939- takenIds . add ( id )
3940- return { ...col , id }
3941- } )
3932+ const outputColumns = data . outputColumns . map ( ( col ) =>
3933+ col . id ? col : { ...col , id : generateColumnId ( ) }
3934+ )
39423935 const updatedColumns = [ ...schema . columns , ...outputColumns ]
39433936 const idByName = new Map ( updatedColumns . map ( ( c ) => [ c . name , getColumnId ( c ) ] ) )
39443937 const group = remapGroupColumnRefs ( data . group , idByName )
@@ -4083,13 +4076,9 @@ export async function updateWorkflowGroup(
40834076 // row-data storage key). New output columns get ids first; then output
40844077 // `columnName`, deps, input mappings, and mapping-update targets are
40854078 // remapped name → id. Callers that already pass ids are unaffected.
4086- const takenIds = new Set ( collectColumnIds ( schema ) )
4087- const newColDefs = ( data . newOutputColumns ?? [ ] ) . map ( ( col ) => {
4088- if ( col . id ) return col
4089- const id = generateColumnId ( takenIds )
4090- takenIds . add ( id )
4091- return { ...col , id }
4092- } )
4079+ const newColDefs = ( data . newOutputColumns ?? [ ] ) . map ( ( col ) =>
4080+ col . id ? col : { ...col , id : generateColumnId ( ) }
4081+ )
40934082 const idByName = new Map (
40944083 [ ...schema . columns , ...newColDefs ] . map ( ( c ) => [ c . name , getColumnId ( c ) ] )
40954084 )
@@ -4474,7 +4463,7 @@ export async function addWorkflowGroupOutput(
44744463 }
44754464
44764465 const newColDef : ColumnDefinition = {
4477- id : generateColumnId ( collectColumnIds ( schema ) ) ,
4466+ id : generateColumnId ( ) ,
44784467 name : columnName ,
44794468 type : newColumnType ,
44804469 required : false ,
0 commit comments