60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
|
import { Table, TableForeignKey } from "typeorm";
|
||
|
import { getTypeByORM } from "../ormHelper";
|
||
|
|
||
|
export const calendar_type_table = new Table({
|
||
|
name: "calendar_type",
|
||
|
columns: [
|
||
|
{ name: "id", type: getTypeByORM("int"), isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||
|
{ name: "type", type: getTypeByORM("varchar"), length: "255", isUnique: true, isNullable: false },
|
||
|
{ name: "nscdr", type: getTypeByORM("boolean"), isNullable: false },
|
||
|
{ name: "color", type: getTypeByORM("varchar"), length: "255", isNullable: false },
|
||
|
{ name: "passphrase", type: getTypeByORM("varchar"), length: "255", isNullable: true },
|
||
|
],
|
||
|
});
|
||
|
|
||
|
export const calendar_table = new Table({
|
||
|
name: "calendar",
|
||
|
columns: [
|
||
|
{
|
||
|
name: "id",
|
||
|
type: getTypeByORM("varchar"),
|
||
|
length: "36",
|
||
|
isPrimary: true,
|
||
|
isGenerated: true,
|
||
|
generationStrategy: "uuid",
|
||
|
},
|
||
|
{ name: "starttime", type: getTypeByORM("datetime"), isNullable: false },
|
||
|
{ name: "endtime", type: getTypeByORM("datetime"), isNullable: false },
|
||
|
{ name: "title", type: getTypeByORM("varchar"), length: "255", isNullable: false },
|
||
|
{ name: "content", type: getTypeByORM("text"), isNullable: true },
|
||
|
{ name: "allDay", type: getTypeByORM("boolean"), isNullable: false, default: false },
|
||
|
{ name: "location", type: getTypeByORM("text"), isNullable: true },
|
||
|
{ name: "sequence", type: getTypeByORM("int"), default: 1 },
|
||
|
{
|
||
|
name: "createdAt",
|
||
|
type: getTypeByORM("datetime"),
|
||
|
precision: 6,
|
||
|
isNullable: false,
|
||
|
default: "CURRENT_TIMESTAMP(6)",
|
||
|
},
|
||
|
{
|
||
|
name: "updatedAt",
|
||
|
type: getTypeByORM("datetime"),
|
||
|
precision: 6,
|
||
|
isNullable: false,
|
||
|
default: "CURRENT_TIMESTAMP(6)",
|
||
|
onUpdate: "CURRENT_TIMESTAMP(6)",
|
||
|
},
|
||
|
{ name: "typeId", type: getTypeByORM("int"), isNullable: false },
|
||
|
],
|
||
|
foreignKeys: [
|
||
|
new TableForeignKey({
|
||
|
columnNames: ["typeId"],
|
||
|
referencedColumnNames: ["id"],
|
||
|
referencedTableName: "calendar_type",
|
||
|
onDelete: "RESTRICT",
|
||
|
onUpdate: "RESTRICT",
|
||
|
}),
|
||
|
],
|
||
|
});
|