protocol tables
This commit is contained in:
parent
edc35f2f87
commit
dd74005043
6 changed files with 262 additions and 0 deletions
|
@ -32,6 +32,11 @@ import { CommunicationFields1727439800630 } from "./migrations/1727439800630-com
|
||||||
import { protocol } from "./entity/protocol";
|
import { protocol } from "./entity/protocol";
|
||||||
import { ProtocolInit1727953803404 } from "./migrations/1727953803404-protocol-init";
|
import { ProtocolInit1727953803404 } from "./migrations/1727953803404-protocol-init";
|
||||||
import { ProtocolBase1728037129072 } from "./migrations/1728037129072-protocolBase";
|
import { ProtocolBase1728037129072 } from "./migrations/1728037129072-protocolBase";
|
||||||
|
import { protocolAgenda } from "./entity/protocolAgenda";
|
||||||
|
import { protocolDecisions } from "./entity/protocolDecisions";
|
||||||
|
import { protocolPresence } from "./entity/protocolPresence";
|
||||||
|
import { protocolVotings } from "./entity/protocolVotings";
|
||||||
|
import { ProtocolTables1728563204766 } from "./migrations/1728563204766-protocolTables";
|
||||||
|
|
||||||
const dataSource = new DataSource({
|
const dataSource = new DataSource({
|
||||||
type: DB_TYPE as any,
|
type: DB_TYPE as any,
|
||||||
|
@ -62,6 +67,10 @@ const dataSource = new DataSource({
|
||||||
memberQualifications,
|
memberQualifications,
|
||||||
membership,
|
membership,
|
||||||
protocol,
|
protocol,
|
||||||
|
protocolAgenda,
|
||||||
|
protocolDecisions,
|
||||||
|
protocolPresence,
|
||||||
|
protocolVotings,
|
||||||
],
|
],
|
||||||
migrations: [
|
migrations: [
|
||||||
Initial1724317398939,
|
Initial1724317398939,
|
||||||
|
@ -74,6 +83,7 @@ const dataSource = new DataSource({
|
||||||
CommunicationFields1727439800630,
|
CommunicationFields1727439800630,
|
||||||
ProtocolInit1727953803404,
|
ProtocolInit1727953803404,
|
||||||
ProtocolBase1728037129072,
|
ProtocolBase1728037129072,
|
||||||
|
ProtocolTables1728563204766,
|
||||||
],
|
],
|
||||||
migrationsRun: true,
|
migrationsRun: true,
|
||||||
migrationsTransactionMode: "each",
|
migrationsTransactionMode: "each",
|
||||||
|
|
21
src/entity/protocolAgenda.ts
Normal file
21
src/entity/protocolAgenda.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { protocol } from "./protocol";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class protocolAgenda {
|
||||||
|
@PrimaryGeneratedColumn("increment")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255 })
|
||||||
|
topic: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
context: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => protocol, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
protocol: protocol;
|
||||||
|
}
|
21
src/entity/protocolDecisions.ts
Normal file
21
src/entity/protocolDecisions.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { protocol } from "./protocol";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class protocolDecisions {
|
||||||
|
@PrimaryGeneratedColumn("increment")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255 })
|
||||||
|
topic: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
context: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => protocol, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
protocol: protocol;
|
||||||
|
}
|
26
src/entity/protocolPresence.ts
Normal file
26
src/entity/protocolPresence.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm";
|
||||||
|
import { protocol } from "./protocol";
|
||||||
|
import { member } from "./member";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class protocolPresence {
|
||||||
|
@PrimaryColumn()
|
||||||
|
memberId: string;
|
||||||
|
|
||||||
|
@PrimaryColumn()
|
||||||
|
protocolId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => member, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
member: member;
|
||||||
|
|
||||||
|
@ManyToOne(() => protocol, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
protocol: protocol;
|
||||||
|
}
|
30
src/entity/protocolVotings.ts
Normal file
30
src/entity/protocolVotings.ts
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { protocol } from "./protocol";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class protocolVotings {
|
||||||
|
@PrimaryGeneratedColumn("increment")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255 })
|
||||||
|
topic: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
context: string;
|
||||||
|
|
||||||
|
@Column({ type: "int", default: 0 })
|
||||||
|
favour: number;
|
||||||
|
|
||||||
|
@Column({ type: "int", default: 0 })
|
||||||
|
abstain: number;
|
||||||
|
|
||||||
|
@Column({ type: "int", default: 0 })
|
||||||
|
against: number;
|
||||||
|
|
||||||
|
@ManyToOne(() => protocol, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
protocol: protocol;
|
||||||
|
}
|
154
src/migrations/1728563204766-protocolTables.ts
Normal file
154
src/migrations/1728563204766-protocolTables.ts
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from "typeorm";
|
||||||
|
import { DB_TYPE } from "../env.defaults";
|
||||||
|
|
||||||
|
export class ProtocolTables1728563204766 implements MigrationInterface {
|
||||||
|
name = "ProtocolTables1728563204766";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
const variableType_int = DB_TYPE == "mysql" ? "int" : "integer";
|
||||||
|
|
||||||
|
await queryRunner.createTable(
|
||||||
|
new Table({
|
||||||
|
name: "protocol_agenda",
|
||||||
|
columns: [
|
||||||
|
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||||
|
{ name: "topic", type: "varchar", length: "255", isNullable: false },
|
||||||
|
{ name: "context", type: "varchar", length: "255", default: "''", isNullable: false },
|
||||||
|
{ name: "protocolId", type: variableType_int, isNullable: false },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.createTable(
|
||||||
|
new Table({
|
||||||
|
name: "protocol_decisions",
|
||||||
|
columns: [
|
||||||
|
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||||
|
{ name: "topic", type: "varchar", length: "255", isNullable: false },
|
||||||
|
{ name: "context", type: "varchar", length: "255", default: "''", isNullable: false },
|
||||||
|
{ name: "protocolId", type: variableType_int, isNullable: false },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.createTable(
|
||||||
|
new Table({
|
||||||
|
name: "protocol_presence",
|
||||||
|
columns: [
|
||||||
|
{ name: "memberId", type: variableType_int, isPrimary: true, isNullable: false },
|
||||||
|
{ name: "protocolId", type: variableType_int, isPrimary: true, isNullable: false },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.createTable(
|
||||||
|
new Table({
|
||||||
|
name: "protocol_votings",
|
||||||
|
columns: [
|
||||||
|
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||||
|
{ name: "topic", type: "varchar", length: "255", isNullable: false },
|
||||||
|
{ name: "context", type: "varchar", length: "255", default: "''", isNullable: false },
|
||||||
|
{ name: "favour", type: variableType_int, default: 0, isNullable: false },
|
||||||
|
{ name: "abstain", type: variableType_int, default: 0, isNullable: false },
|
||||||
|
{ name: "against", type: variableType_int, default: 0, isNullable: false },
|
||||||
|
{ name: "protocolId", type: variableType_int, isNullable: false },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.createForeignKey(
|
||||||
|
"protocol_agenda",
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["protocolId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "protocol",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.createForeignKey(
|
||||||
|
"protocol_decisions",
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["protocolId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "protocol",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.createForeignKey(
|
||||||
|
"protocol_votings",
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["protocolId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "protocol",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.createForeignKey(
|
||||||
|
"protocol_presence",
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["protocolId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "protocol",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await queryRunner.createForeignKey(
|
||||||
|
"protocol_presence",
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["memberId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "member",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
const tableProtocolVotings = await queryRunner.getTable("protocol_votings");
|
||||||
|
const foreignKeyProtocolVotings = tableProtocolVotings.foreignKeys.find(
|
||||||
|
(fk) => fk.columnNames.indexOf("protocolId") !== -1
|
||||||
|
);
|
||||||
|
await queryRunner.dropForeignKey("protocol_votings", foreignKeyProtocolVotings);
|
||||||
|
|
||||||
|
const tableProtocolDecisions = await queryRunner.getTable("protocol_decisions");
|
||||||
|
const foreignKeyProtocolDecisions = tableProtocolDecisions.foreignKeys.find(
|
||||||
|
(fk) => fk.columnNames.indexOf("protocolId") !== -1
|
||||||
|
);
|
||||||
|
await queryRunner.dropForeignKey("protocol_decisions", foreignKeyProtocolDecisions);
|
||||||
|
|
||||||
|
const tableProtocolAgenda = await queryRunner.getTable("protocol_agenda");
|
||||||
|
const foreignKeyProtocolAgenda = tableProtocolAgenda.foreignKeys.find(
|
||||||
|
(fk) => fk.columnNames.indexOf("protocolId") !== -1
|
||||||
|
);
|
||||||
|
await queryRunner.dropForeignKey("protocol_agenda", foreignKeyProtocolAgenda);
|
||||||
|
|
||||||
|
const tableProtocolPresence_protcol = await queryRunner.getTable("protocol_presence");
|
||||||
|
const foreignKeyProtocolPresence_protcol = tableProtocolPresence_protcol.foreignKeys.find(
|
||||||
|
(fk) => fk.columnNames.indexOf("protocolId") !== -1
|
||||||
|
);
|
||||||
|
await queryRunner.dropForeignKey("protocol_presence", foreignKeyProtocolPresence_protcol);
|
||||||
|
|
||||||
|
const tableProtocolPresence_member = await queryRunner.getTable("protocol_presence");
|
||||||
|
const foreignKeyProtocolPresence_member = tableProtocolPresence_member.foreignKeys.find(
|
||||||
|
(fk) => fk.columnNames.indexOf("memberId") !== -1
|
||||||
|
);
|
||||||
|
await queryRunner.dropForeignKey("protocol_presence", foreignKeyProtocolPresence_member);
|
||||||
|
|
||||||
|
await queryRunner.dropTable("protocol_votings");
|
||||||
|
await queryRunner.dropTable("protocol_presence");
|
||||||
|
await queryRunner.dropTable("protocol_decisions");
|
||||||
|
await queryRunner.dropTable("protocol_agenda");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue