Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

Fix table id on relationships in postgres import (#1084)

1ilitc6e3ba9b72ab
diff --git a/src/utils/importSQL/postgres.js b/src/utils/importSQL/postgres.js
index e8c028c0..397d6080 100644
--- a/src/utils/importSQL/postgres.js
+++ b/src/utils/importSQL/postgres.js
@@ -232,8 +232,6 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
}
});
- const startTableId = tables.length;
-
const endTable = tables.find((t) => t.name === endTableName);
if (!endTable) return;
@@ -248,7 +246,7 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
if (!startField) return;
relationship.name = `fk_${startTableName}_${startFieldName}_${endTableName}`;
- relationship.startTableId = startTableId;
+ relationship.startTableId = table.id;
relationship.startFieldId = startField.id;
relationship.endTableId = endTable.id;
relationship.endFieldId = endField.id;