backup and base schema creation

This commit is contained in:
Julian Krauser 2025-01-30 15:58:34 +01:00
parent a91b723f04
commit b7b6694407
11 changed files with 1030 additions and 46 deletions

View file

@ -0,0 +1,57 @@
import { Table, TableForeignKey } from "typeorm";
import { getTypeByORM } from "../ormHelper";
export const query_table = new Table({
name: "query",
columns: [
{ name: "id", type: getTypeByORM("int"), isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "title", type: getTypeByORM("varchar"), length: "255", isNullable: false, isUnique: true },
{ name: "query", type: getTypeByORM("text"), isNullable: false, default: "''" },
],
});
export const template_table = new Table({
name: "template",
columns: [
{ name: "id", type: getTypeByORM("int"), isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "template", type: getTypeByORM("varchar"), length: "255", isNullable: false, isUnique: true },
{ name: "description", type: getTypeByORM("varchar"), length: "255", isNullable: true },
{ name: "design", type: getTypeByORM("text"), isNullable: false, default: "'{}'" },
{ name: "html", type: getTypeByORM("text"), isNullable: false, default: "''" },
],
});
export const template_usage_table = new Table({
name: "template_usage",
columns: [
{ name: "scope", type: getTypeByORM("varchar"), length: "255", isPrimary: true },
{ name: "headerId", type: getTypeByORM("int"), isNullable: true },
{ name: "bodyId", type: getTypeByORM("int"), isNullable: true },
{ name: "footerId", type: getTypeByORM("int"), isNullable: true },
{ name: "headerHeight", type: getTypeByORM("int"), default: null, isNullable: true },
{ name: "footerHeight", type: getTypeByORM("int"), default: null, isNullable: true },
],
foreignKeys: [
new TableForeignKey({
columnNames: ["headerId"],
referencedColumnNames: ["id"],
referencedTableName: "template",
onDelete: "RESTRICT",
onUpdate: "RESTRICT",
}),
new TableForeignKey({
columnNames: ["bodyId"],
referencedColumnNames: ["id"],
referencedTableName: "template",
onDelete: "RESTRICT",
onUpdate: "RESTRICT",
}),
new TableForeignKey({
columnNames: ["footerId"],
referencedColumnNames: ["id"],
referencedTableName: "template",
onDelete: "RESTRICT",
onUpdate: "RESTRICT",
}),
],
});