ff-admin-server/src/migrations/baseSchemaTables/protocol.ts

122 lines
4.6 KiB
TypeScript
Raw Normal View History

2025-01-30 15:58:34 +01:00
import { Table, TableForeignKey } from "typeorm";
import { getTypeByORM } from "../ormHelper";
export const protocol_table = new Table({
name: "protocol",
columns: [
{ name: "id", type: getTypeByORM("int"), isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "title", type: getTypeByORM("varchar"), length: "255", isNullable: false },
{ name: "date", type: getTypeByORM("date"), isNullable: false },
{ name: "starttime", type: getTypeByORM("time"), isNullable: true },
{ name: "endtime", type: getTypeByORM("time"), isNullable: true },
{ name: "summary", type: getTypeByORM("text"), isNullable: true },
],
});
export const protocol_agenda_table = new Table({
name: "protocol_agenda",
columns: [
{ name: "id", type: getTypeByORM("int"), isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "topic", type: getTypeByORM("varchar"), length: "255", isNullable: false },
{ name: "context", type: getTypeByORM("text"), default: "''", isNullable: false },
{ name: "protocolId", type: getTypeByORM("int"), isNullable: false },
],
foreignKeys: [
new TableForeignKey({
columnNames: ["protocolId"],
referencedColumnNames: ["id"],
referencedTableName: "protocol",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
}),
],
});
export const protocol_decision_table = new Table({
name: "protocol_decision",
columns: [
{ name: "id", type: getTypeByORM("int"), isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "topic", type: getTypeByORM("varchar"), length: "255", isNullable: false },
{ name: "context", type: getTypeByORM("text"), default: "''", isNullable: false },
{ name: "protocolId", type: getTypeByORM("int"), isNullable: false },
],
foreignKeys: [
new TableForeignKey({
columnNames: ["protocolId"],
referencedColumnNames: ["id"],
referencedTableName: "protocol",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
}),
],
});
export const protocol_presence_table = new Table({
name: "protocol_presence",
columns: [
{ name: "memberId", type: getTypeByORM("varchar"), isPrimary: true },
{ name: "protocolId", type: getTypeByORM("int"), isPrimary: true },
{ name: "absent", type: getTypeByORM("boolean"), default: false, isNullable: false },
{ name: "excused", type: getTypeByORM("boolean"), default: false, isNullable: false },
],
foreignKeys: [
new TableForeignKey({
columnNames: ["protocolId"],
referencedColumnNames: ["id"],
referencedTableName: "protocol",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
}),
new TableForeignKey({
columnNames: ["memberId"],
referencedColumnNames: ["id"],
referencedTableName: "member",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
}),
],
});
export const protocol_voting_table = new Table({
name: "protocol_voting",
columns: [
{ name: "id", type: getTypeByORM("int"), isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "topic", type: getTypeByORM("varchar"), length: "255", isNullable: false },
{ name: "context", type: getTypeByORM("text"), default: "''", isNullable: false },
{ name: "favour", type: getTypeByORM("int"), default: 0, isNullable: false },
{ name: "abstain", type: getTypeByORM("int"), default: 0, isNullable: false },
{ name: "against", type: getTypeByORM("int"), default: 0, isNullable: false },
{ name: "protocolId", type: getTypeByORM("int"), isNullable: false },
],
foreignKeys: [
new TableForeignKey({
columnNames: ["protocolId"],
referencedColumnNames: ["id"],
referencedTableName: "protocol",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
}),
],
});
export const protocol_printout_table = new Table({
name: "protocol_printout",
columns: [
{ name: "id", type: getTypeByORM("int"), isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "title", type: getTypeByORM("varchar"), length: "255", isNullable: false },
{ name: "iteration", type: getTypeByORM("int"), default: 1, isNullable: false },
{ name: "filename", type: getTypeByORM("varchar"), length: "255", isNullable: false },
{ name: "createdAt", type: getTypeByORM("datetime"), isNullable: false, default: "CURRENT_TIMESTAMP(6)" },
{ name: "protocolId", type: getTypeByORM("int"), isNullable: false },
],
foreignKeys: [
new TableForeignKey({
columnNames: ["protocolId"],
referencedColumnNames: ["id"],
referencedTableName: "protocol",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
}),
],
});