Skip to content

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

Fix diagram format in export all saved data (#989)

1ilit5a93548d8387
diff --git a/src/data/schemas.js b/src/data/schemas.js
index a82d41ad..23a50844 100644
--- a/src/data/schemas.js
+++ b/src/data/schemas.js
@@ -89,6 +89,7 @@ export const noteSchema = {
content: { type: "string" },
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
height: { type: "number" },
+ width: { type: "number" },
locked: { type: "boolean" },
},
required: ["id", "x", "y", "title", "content", "color", "height"],
@@ -195,6 +196,7 @@ export const jsonSchema = {
database: { type: "string" },
},
required: ["tables", "relationships", "notes", "subjectAreas"],
+ additionalProperties: true,
};
export const ddbSchema = {
diff --git a/src/utils/exportSavedData.js b/src/utils/exportSavedData.js
index 00e6cf07..4c8f5ffd 100644
--- a/src/utils/exportSavedData.js
+++ b/src/utils/exportSavedData.js
@@ -4,13 +4,24 @@ import { saveAs } from "file-saver";
const zip = new JSZip();
+const formatDiagram = (diagram) => {
+ const formattedDiagram = { ...diagram };
+ formattedDiagram.relationships = diagram.references;
+ formattedDiagram.subjectAreas = diagram.areas;
+
+ delete formattedDiagram.references;
+ delete formattedDiagram.areas;
+
+ return formattedDiagram;
+};
+
export async function exportSavedData() {
const diagramsFolder = zip.folder("diagrams");
await db.diagrams.each((diagram) => {
diagramsFolder.file(
`${diagram.name}(${diagram.id}).json`,
- JSON.stringify(diagram, null, 2),
+ JSON.stringify(formatDiagram(diagram), null, 2),
);
return true;
});
@@ -20,7 +31,7 @@ export async function exportSavedData() {
await db.templates.where({ custom: 1 }).each((template) => {
templatesFolder.file(
`${template.title}(${template.id}).json`,
- JSON.stringify(template, null, 2),
+ JSON.stringify(formatDiagram(template), null, 2),
);
return true;
});