@@ -152,6 +152,8 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
152152 relationship . endTableId = endTable . id ;
153153 relationship . endFieldId = endField . id ;
154154 relationship . startFieldId = startField . id ;
155+ relationship . id = nanoid ( ) ;
156+
155157 let updateConstraint = Constraint . NONE ;
156158 let deleteConstraint = Constraint . NONE ;
157159 d . reference_definition . on_action . forEach ( ( c ) => {
@@ -224,6 +226,7 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
224226 relationship . endFieldId = endField . id ;
225227 relationship . updateConstraint = updateConstraint ;
226228 relationship . deleteConstraint = deleteConstraint ;
229+ relationship . id = nanoid ( ) ;
227230
228231 if ( startField . unique ) {
229232 relationship . cardinality = Cardinality . ONE_TO_ONE ;
@@ -232,8 +235,6 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
232235 }
233236
234237 relationships . push ( relationship ) ;
235-
236- relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
237238 }
238239 } ) ;
239240 tables . push ( table ) ;
@@ -347,6 +348,7 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
347348 relationship . updateConstraint = updateConstraint ;
348349 relationship . deleteConstraint = deleteConstraint ;
349350 relationship . cardinality = Cardinality . ONE_TO_ONE ;
351+ relationship . id = nanoid ( ) ;
350352
351353 if ( startField . unique ) {
352354 relationship . cardinality = Cardinality . ONE_TO_ONE ;
@@ -355,8 +357,6 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
355357 }
356358
357359 relationships . push ( relationship ) ;
358-
359- relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
360360 }
361361 } ) ;
362362 }
@@ -386,7 +386,5 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
386386 parseSingleStatement ( ast ) ;
387387 }
388388
389- relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
390-
391389 return { tables, relationships, types, enums } ;
392390}
0 commit comments