@@ -152,6 +152,8 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
152
152
relationship . endTableId = endTable . id ;
153
153
relationship . endFieldId = endField . id ;
154
154
relationship . startFieldId = startField . id ;
155
+ relationship . id = nanoid ( ) ;
156
+
155
157
let updateConstraint = Constraint . NONE ;
156
158
let deleteConstraint = Constraint . NONE ;
157
159
d . reference_definition . on_action . forEach ( ( c ) => {
@@ -224,6 +226,7 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
224
226
relationship . endFieldId = endField . id ;
225
227
relationship . updateConstraint = updateConstraint ;
226
228
relationship . deleteConstraint = deleteConstraint ;
229
+ relationship . id = nanoid ( ) ;
227
230
228
231
if ( startField . unique ) {
229
232
relationship . cardinality = Cardinality . ONE_TO_ONE ;
@@ -232,8 +235,6 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
232
235
}
233
236
234
237
relationships . push ( relationship ) ;
235
-
236
- relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
237
238
}
238
239
} ) ;
239
240
tables . push ( table ) ;
@@ -347,6 +348,7 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
347
348
relationship . updateConstraint = updateConstraint ;
348
349
relationship . deleteConstraint = deleteConstraint ;
349
350
relationship . cardinality = Cardinality . ONE_TO_ONE ;
351
+ relationship . id = nanoid ( ) ;
350
352
351
353
if ( startField . unique ) {
352
354
relationship . cardinality = Cardinality . ONE_TO_ONE ;
@@ -355,8 +357,6 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
355
357
}
356
358
357
359
relationships . push ( relationship ) ;
358
-
359
- relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
360
360
}
361
361
} ) ;
362
362
}
@@ -386,7 +386,5 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
386
386
parseSingleStatement ( ast ) ;
387
387
}
388
388
389
- relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
390
-
391
389
return { tables, relationships, types, enums } ;
392
390
}
0 commit comments