backup and base schema creation
This commit is contained in:
parent
a91b723f04
commit
b7b6694407
11 changed files with 1030 additions and 46 deletions
59
src/migrations/baseSchemaTables/calendar.ts
Normal file
59
src/migrations/baseSchemaTables/calendar.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
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",
|
||||
}),
|
||||
],
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue