Seed templates

This commit is contained in:
1ilit 2023-12-02 23:27:25 +02:00
parent aae695a61e
commit 407e060b77
2 changed files with 266 additions and 1 deletions

View File

@ -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 };

259
src/data/seeds.js Normal file
View File

@ -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 };