Skip to content

Commit 3647e88

Browse files
committed
bump version to 0.0.137; add support for existing foreign keys in schema designer
1 parent 65a3376 commit 3647e88

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "azdataGraph",
33
"description": "azdataGraph is a derivative of mxGraph, which is a fully client side JavaScript diagramming library that uses SVG and HTML for rendering.",
4-
"version": "0.0.136",
4+
"version": "0.0.137",
55
"homepage": "https://github.com/microsoft/azdataGraph",
66
"author": "Microsoft",
77
"license": "Apache-2.0",

src/ts/schemaDesigner/schemaDesigner.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,22 @@ export class SchemaDesigner {
354354
const targetCellState = (this as any).currentState as mxCellState;
355355
if (targetCellState?.cell?.value) {
356356
const targetCellValue = targetCellState.cell.value as SchemaDesignerTable;
357+
// Existing foreign key between source and target
358+
const edgeBetweenSourceAndTarget = this.graph.model.getEdgesBetween((this as any).previous.cell, targetCellState.cell);
359+
let existingForeignKey: EdgeCellValue | undefined = undefined;
360+
if (edgeBetweenSourceAndTarget.length > 0) {
361+
existingForeignKey = edgeBetweenSourceAndTarget[0].value as EdgeCellValue;
362+
}
357363
if (cellValue) {
358364
const targetColumnName = targetCellValue.columns[this.currentRow - 1].name;
359365
cellValue.targetRow = this.currentRow;
360366
cellValue.referencedColumns = [targetColumnName];
361367
cellValue.referencedSchemaName = targetCellValue.schema;
362368
cellValue.referencedTableName = targetCellValue.name;
363369
cellValue.name = `FK_${sourceTableValue.name}_${cellValue.referencedTableName}`;
370+
if (existingForeignKey !== undefined) {
371+
cellValue.id = existingForeignKey.id;
372+
}
364373
}
365374
}
366375
} else {
@@ -428,7 +437,6 @@ export class SchemaDesigner {
428437

429438
const edgeState = this.edgeState;
430439
const edgeStateValue = edgeState.cell.value as EdgeCellValue;
431-
console.log(edgeStateValue.sourceRow, edgeStateValue.targetRow);
432440
const edgeBetweenSourceAndTarget = this.graph.model.getEdgesBetween(source, target);
433441
for (let i = 0; i < edgeBetweenSourceAndTarget.length; i++) {
434442
const edge = edgeBetweenSourceAndTarget[i];

0 commit comments

Comments
 (0)