58 lines
2.2 KiB
TypeScript
58 lines
2.2 KiB
TypeScript
|
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",
|
||
|
}),
|
||
|
],
|
||
|
});
|