diff --git a/src/data/db.js b/src/data/db.js index 620a2fc..62bac55 100644 --- a/src/data/db.js +++ b/src/data/db.js @@ -1,9 +1,15 @@ import Dexie from "dexie"; +import { templateSeeds } from "./seeds"; const db = new Dexie("drawDB"); -db.version(1).stores({ +db.version(2).stores({ diagrams: "++id, lastModified", + templates: "++id", +}); + +db.on("populate", (transaction) => { + transaction.templates.bulkAdd(templateSeeds).catch((e) => console.log(e)); }); export { db }; diff --git a/src/data/seeds.js b/src/data/seeds.js new file mode 100644 index 0000000..ce6691a --- /dev/null +++ b/src/data/seeds.js @@ -0,0 +1,259 @@ +const t1 = { + tables: [ + { + id: 0, + name: "template_1", + x: 57, + y: 63, + fields: [ + { + name: "id", + type: "INT", + default: "", + check: "", + primary: true, + unique: true, + notNull: true, + increment: true, + comment: "", + id: 0, + }, + ], + comment: "", + indices: [], + color: "#f03c3c", + }, + ], + relationships: [], + notes: [], + subjectAreas: [], + types: [], +}; + +const t2 = { + tables: [ + { + id: 0, + name: "template_2", + x: 57, + y: 63, + fields: [ + { + name: "id", + type: "INT", + default: "", + check: "", + primary: true, + unique: true, + notNull: true, + increment: true, + comment: "", + id: 0, + }, + ], + comment: "", + indices: [], + color: "#ff4f81", + }, + ], + relationships: [], + notes: [], + subjectAreas: [], + types: [], +}; + +const t3 = { + tables: [ + { + id: 0, + name: "template_3", + x: 57, + y: 63, + fields: [ + { + name: "id", + type: "INT", + default: "", + check: "", + primary: true, + unique: true, + notNull: true, + increment: true, + comment: "", + id: 0, + }, + ], + comment: "", + indices: [], + color: "#bc49c4", + }, + ], + relationships: [], + notes: [], + subjectAreas: [], + types: [], +}; + +const t4 = { + tables: [ + { + id: 0, + name: "template_4", + x: 57, + y: 63, + fields: [ + { + name: "id", + type: "INT", + default: "", + check: "", + primary: true, + unique: true, + notNull: true, + increment: true, + comment: "", + id: 0, + }, + ], + comment: "", + indices: [], + color: "#a751e8", + }, + ], + relationships: [], + notes: [], + subjectAreas: [], + types: [], +}; + +const t5 = { + tables: [ + { + id: 0, + name: "template_5", + x: 57, + y: 63, + fields: [ + { + name: "id", + type: "INT", + default: "", + check: "", + primary: true, + unique: true, + notNull: true, + increment: true, + comment: "", + id: 0, + }, + ], + comment: "", + indices: [], + color: "#7c4af0", + }, + ], + relationships: [], + notes: [], + subjectAreas: [], + types: [], +}; + +const t6 = { + tables: [ + { + id: 0, + name: "template_6", + x: 57, + y: 63, + fields: [ + { + name: "id", + type: "INT", + default: "", + check: "", + primary: true, + unique: true, + notNull: true, + increment: true, + comment: "", + id: 0, + }, + ], + comment: "", + indices: [], + color: "#6360f7", + }, + ], + relationships: [], + notes: [], + subjectAreas: [], + types: [], +}; + +const t7 = { + tables: [ + { + id: 0, + name: "template_7", + x: 57, + y: 63, + fields: [ + { + name: "id", + type: "INT", + default: "", + check: "", + primary: true, + unique: true, + notNull: true, + increment: true, + comment: "", + id: 0, + }, + ], + comment: "", + indices: [], + color: "#7d9dff", + }, + ], + relationships: [], + notes: [], + subjectAreas: [], + types: [], +}; + +const t8 = { + tables: [ + { + id: 0, + name: "template_8", + x: 57, + y: 63, + fields: [ + { + name: "id", + type: "INT", + default: "", + check: "", + primary: true, + unique: true, + notNull: true, + increment: true, + comment: "", + id: 0, + }, + ], + comment: "", + indices: [], + color: "#32c9b0", + }, + ], + relationships: [], + notes: [], + subjectAreas: [], + types: [], +}; + +const templateSeeds = [t1, t2, t3, t4, t5, t6, t7, t8]; + +export { templateSeeds };