diff --git a/data-source.ts b/data-source.ts index 4357167..5c68960 100644 --- a/data-source.ts +++ b/data-source.ts @@ -3,15 +3,17 @@ import "reflect-metadata"; import { DataSource } from "typeorm"; import { award } from "./entities/award"; import { communication } from "./entities/communication"; -import { executive_position } from "./entities/executive_position"; -import { member_awards } from "./entities/member_awards"; -import { member_executive_positions } from "./entities/member_executive_positions"; -import { member_qualifications } from "./entities/member_qualifications"; +import { communicationType } from "./entities/communicationType"; +import { executivePosition } from "./entities/executivePosition"; +import { memberAwards } from "./entities/memberAwards"; +import { memberExecutivePositions } from "./entities/memberExecutivePositions"; +import { memberQualifications } from "./entities/memberQualifications"; import { member } from "./entities/member"; import { membership } from "./entities/membership"; -import { membership_status } from "./entities/membership_status"; +import { membershipStatus } from "./entities/membershipStatus"; import { qualification } from "./entities/qualification"; import { Initial1724242210553 } from "./migrations/1724242210553-initial"; +import { NamingAndCleanup1724396667634 } from "./migrations/1724396667634-namingAndCleanup"; const dataSource = new DataSource({ type: "mysql", @@ -26,16 +28,17 @@ const dataSource = new DataSource({ entities: [ award, communication, - executive_position, - member_awards, - member_executive_positions, - member_qualifications, + communicationType, + executivePosition, + memberAwards, + memberExecutivePositions, + memberQualifications, member, membership, - membership_status, + membershipStatus, qualification, ], - migrations: [Initial1724242210553], + migrations: [Initial1724242210553, NamingAndCleanup1724396667634], migrationsRun: true, migrationsTransactionMode: "each", subscribers: [], diff --git a/entities/award.ts b/entities/award.ts index 0271658..04a05f3 100644 --- a/entities/award.ts +++ b/entities/award.ts @@ -1,5 +1,5 @@ import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; -import { member_awards } from "./member_awards"; +import { memberAwards } from "./memberAwards"; @Entity() export class award { @@ -9,8 +9,8 @@ export class award { @Column({ type: "varchar", length: 255 }) award: string; - @OneToMany(() => member_awards, (member) => member.award, { + @OneToMany(() => memberAwards, (member) => member.award, { onDelete: "RESTRICT", }) - members: member_awards[]; + members: memberAwards[]; } diff --git a/entities/communication.ts b/entities/communication.ts index 90ec3cc..c3d5e66 100644 --- a/entities/communication.ts +++ b/entities/communication.ts @@ -1,15 +1,12 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { member } from "./member"; -import { CommunicationType } from "../enums/membership_type"; +import { communicationType } from "./communicationType"; @Entity() export class communication { @PrimaryColumn({ generated: "increment", type: "int" }) id: number; - @Column({ type: "enum", enum: CommunicationType, default: CommunicationType.Phone }) - type: CommunicationType; - @Column({ type: "boolean", default: false }) preffered: boolean; @@ -29,7 +26,10 @@ export class communication { streetnumber: number; @Column({ type: "varchar", length: 255 }) - streetnumber_addition: string; + streetnumberAddition: string; + + @ManyToOne(() => communicationType, (communicationType) => communicationType.communications) + type: communicationType; @ManyToOne(() => member, (member) => member.awards, { onDelete: "RESTRICT", diff --git a/entities/communicationType.ts b/entities/communicationType.ts new file mode 100644 index 0000000..cdee92c --- /dev/null +++ b/entities/communicationType.ts @@ -0,0 +1,19 @@ +import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; +import { communication } from "./communication"; + +@Entity() +export class communicationType { + @PrimaryColumn({ generated: "increment", type: "int" }) + id: number; + + @Column({ type: "varchar", length: 255 }) + type: string; + + @Column({ type: "varchar", length: 255, default: "" }) + useColumns: string; + + @OneToMany(() => communication, (communication) => communication.type, { + onDelete: "RESTRICT", + }) + communications: communication[]; +} diff --git a/entities/executivePosition.ts b/entities/executivePosition.ts new file mode 100644 index 0000000..9b8c8fb --- /dev/null +++ b/entities/executivePosition.ts @@ -0,0 +1,19 @@ +import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; +import { memberExecutivePositions } from "./memberExecutivePositions"; + +@Entity() +export class executivePosition { + @PrimaryColumn({ generated: "increment", type: "int" }) + id: number; + + @Column({ type: "varchar", length: 255 }) + postition: string; + + @Column({ type: "int", default: -1 }) + numberOfPerformers: string; + + @OneToMany(() => memberExecutivePositions, (memberExecutivePositions) => memberExecutivePositions.executivePosition, { + onDelete: "RESTRICT", + }) + members: memberExecutivePositions[]; +} diff --git a/entities/executive_position.ts b/entities/executive_position.ts deleted file mode 100644 index 9d81c03..0000000 --- a/entities/executive_position.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; -import { member_executive_positions } from "./member_executive_positions"; - -@Entity() -export class executive_position { - @PrimaryColumn({ generated: "increment", type: "int" }) - id: number; - - @Column({ type: "varchar", length: 255 }) - postition: string; - - @Column({ type: "int", default: -1 }) - number_of_performers: string; - - @OneToMany( - () => member_executive_positions, - (member_executive_positions) => member_executive_positions.executive_position, - { - onDelete: "RESTRICT", - } - ) - members: member_executive_positions[]; -} diff --git a/entities/member.ts b/entities/member.ts index 33f5a06..ea36daa 100644 --- a/entities/member.ts +++ b/entities/member.ts @@ -1,9 +1,9 @@ -import { Column, Entity, ManyToOne, OneToMany, OneToOne, PrimaryColumn } from "typeorm"; +import { Column, Entity, JoinColumn, ManyToOne, OneToMany, OneToOne, PrimaryColumn } from "typeorm"; import { Salutation } from "../enums/salutation"; import { membership } from "./membership"; -import { member_awards } from "./member_awards"; -import { member_qualifications } from "./member_qualifications"; -import { member_executive_positions } from "./member_executive_positions"; +import { memberAwards } from "./memberAwards"; +import { memberQualifications } from "./memberQualifications"; +import { memberExecutivePositions } from "./memberExecutivePositions"; import { communication } from "./communication"; @Entity() @@ -11,9 +11,6 @@ export class member { @PrimaryColumn({ generated: "increment", type: "int" }) id: number; - @Column({ type: "varchar", length: 255, unique: true, nullable: true }) - member_id?: string; - @Column({ type: "enum", enum: Salutation, default: Salutation.none }) salutation: Salutation; @@ -29,35 +26,33 @@ export class member { @Column({ type: "date" }) birthdate: Date; - @Column({ type: "date", nullable: true, default: null }) - deathdate?: Date; - @Column({ type: "varchar", length: 255, unique: true, nullable: true }) - sepa_mandat?: string; + sepaMandat?: string; - @ManyToOne(() => communication, (member_communications) => member_communications.member) + @OneToMany(() => communication, (communications) => communications.member) communications: communication; @OneToOne(() => communication, { nullable: true, }) + @JoinColumn() sendNewsletter: communication; @OneToMany(() => membership, (membership) => membership.member) memberships: membership[]; - @OneToMany(() => member_executive_positions, (member_executive_positions) => member_executive_positions.member, { + @OneToMany(() => memberExecutivePositions, (executivePositions) => executivePositions.member, { onDelete: "CASCADE", }) - positions: member_executive_positions[]; + positions: memberExecutivePositions[]; - @OneToMany(() => member_qualifications, (qualification) => qualification.member, { + @OneToMany(() => memberQualifications, (qualifications) => qualifications.member, { onDelete: "CASCADE", }) - qualifications: member_qualifications[]; + qualifications: memberQualifications[]; - @OneToMany(() => member_awards, (awards) => awards.member, { + @OneToMany(() => memberAwards, (awards) => awards.member, { onDelete: "CASCADE", }) - awards: member_awards[]; + awards: memberAwards[]; } diff --git a/entities/member_awards.ts b/entities/memberAwards.ts similarity index 95% rename from entities/member_awards.ts rename to entities/memberAwards.ts index 5e73d22..6aa841e 100644 --- a/entities/member_awards.ts +++ b/entities/memberAwards.ts @@ -3,7 +3,7 @@ import { member } from "./member"; import { award } from "./award"; @Entity() -export class member_awards { +export class memberAwards { @PrimaryColumn({ generated: "increment", type: "int" }) id: number; diff --git a/entities/member_executive_positions.ts b/entities/memberExecutivePositions.ts similarity index 58% rename from entities/member_executive_positions.ts rename to entities/memberExecutivePositions.ts index 087c4b6..8763d77 100644 --- a/entities/member_executive_positions.ts +++ b/entities/memberExecutivePositions.ts @@ -1,28 +1,28 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { member } from "./member"; -import { executive_position } from "./executive_position"; +import { executivePosition } from "./executivePosition"; @Entity() -export class member_executive_positions { +export class memberExecutivePositions { @PrimaryColumn({ generated: "increment", type: "int" }) id: number; - @Column({ type: "boolean", default: true }) - given: boolean; - @Column({ type: "varchar", length: 255, nullable: true, default: null }) note?: string; @Column({ type: "date" }) - date: Date; + start: Date; + + @Column({ type: "date" }) + end: Date; @ManyToOne(() => member, (member) => member.awards, { onDelete: "RESTRICT", }) member: member; - @ManyToOne(() => executive_position, (executive_position) => executive_position.members, { + @ManyToOne(() => executivePosition, (executivePosition) => executivePosition.members, { onDelete: "RESTRICT", }) - executive_position: executive_position; + executivePosition: executivePosition; } diff --git a/entities/member_qualifications.ts b/entities/memberQualifications.ts similarity index 85% rename from entities/member_qualifications.ts rename to entities/memberQualifications.ts index a69274a..9528dd4 100644 --- a/entities/member_qualifications.ts +++ b/entities/memberQualifications.ts @@ -3,13 +3,10 @@ import { member } from "./member"; import { qualification } from "./qualification"; @Entity() -export class member_qualifications { +export class memberQualifications { @PrimaryColumn({ generated: "increment", type: "int" }) id: number; - @Column({ type: "boolean", default: true }) - given: boolean; - @Column({ type: "varchar", length: 255, nullable: true, default: null }) note?: string; diff --git a/entities/membership.ts b/entities/membership.ts index 81664bf..ea54678 100644 --- a/entities/membership.ts +++ b/entities/membership.ts @@ -1,12 +1,15 @@ import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm"; import { member } from "./member"; -import { membership_status } from "./membership_status"; +import { membershipStatus } from "./membershipStatus"; @Entity() export class membership { @PrimaryColumn({ generated: "increment", type: "int" }) id: number; + @Column({ type: "varchar", length: 255, unique: true, nullable: true }) + internalId?: string; + @Column({ type: "date" }) start: Date; @@ -14,13 +17,13 @@ export class membership { end?: Date; @Column({ type: "varchar", length: 255, nullable: true }) - termination_reason?: string; + terminationReason?: string; @ManyToOne(() => member, (member) => member.memberships) @JoinColumn() member: member; - @ManyToOne(() => membership_status, (membership_status) => membership_status.memberships) + @ManyToOne(() => membershipStatus, (membershipStatus) => membershipStatus.memberships) @JoinColumn() - status: membership_status; + status: membershipStatus; } diff --git a/entities/membership_status.ts b/entities/membershipStatus.ts similarity index 76% rename from entities/membership_status.ts rename to entities/membershipStatus.ts index 5f12fbe..980d88b 100644 --- a/entities/membership_status.ts +++ b/entities/membershipStatus.ts @@ -2,11 +2,11 @@ import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; import { membership } from "./membership"; @Entity() -export class membership_status { +export class membershipStatus { @PrimaryColumn({ generated: "increment", type: "int" }) id: number; - @Column({ type: "varchar", length: 255, nullable: true }) + @Column({ type: "varchar", length: 255 }) status: string; @OneToMany(() => membership, (membership) => membership.status) diff --git a/entities/qualification.ts b/entities/qualification.ts index 0748f95..271f789 100644 --- a/entities/qualification.ts +++ b/entities/qualification.ts @@ -1,5 +1,5 @@ import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; -import { member_qualifications } from "./member_qualifications"; +import { memberQualifications } from "./memberQualifications"; @Entity() export class qualification { @@ -12,8 +12,8 @@ export class qualification { @Column({ type: "varchar", length: 255, nullable: true, default: null }) description?: string; - @OneToMany(() => member_qualifications, (member_qualifications) => member_qualifications.qualification, { + @OneToMany(() => memberQualifications, (memberQualifications) => memberQualifications.qualification, { onDelete: "RESTRICT", }) - members: member_qualifications[]; + members: memberQualifications[]; } diff --git a/enums/membership_type.ts b/enums/membership_type.ts deleted file mode 100644 index f50aec0..0000000 --- a/enums/membership_type.ts +++ /dev/null @@ -1,7 +0,0 @@ -export enum CommunicationType { - Phone = "phone", - Mobile = "mobile", - Address = "address", - Mail = "mail", - InternalMail = "internalMail", -} diff --git a/index.ts b/index.ts index c220e10..62375ea 100644 --- a/index.ts +++ b/index.ts @@ -4,14 +4,13 @@ import "reflect-metadata"; export { dataSource } from "./data-source"; export { award } from "./entities/award"; export { communication } from "./entities/communication"; -export { executive_position } from "./entities/executive_position"; -export { member_awards } from "./entities/member_awards"; -export { member_executive_positions } from "./entities/member_executive_positions"; -export { member_qualifications } from "./entities/member_qualifications"; +export { executivePosition as executive_position } from "./entities/executivePosition"; +export { memberAwards as member_awards } from "./entities/memberAwards"; +export { memberExecutivePositions as member_executive_positions } from "./entities/memberExecutivePositions"; +export { memberQualifications as member_qualifications } from "./entities/memberQualifications"; export { member } from "./entities/member"; export { membership } from "./entities/membership"; -export { membership_status } from "./entities/membership_status"; +export { membershipStatus as membership_status } from "./entities/membershipStatus"; export { qualification } from "./entities/qualification"; -export { CommunicationType } from "./enums/membership_type"; export { Salutation } from "./enums/salutation"; diff --git a/migrations/1724396667634-namingAndCleanup.ts b/migrations/1724396667634-namingAndCleanup.ts new file mode 100644 index 0000000..562529a --- /dev/null +++ b/migrations/1724396667634-namingAndCleanup.ts @@ -0,0 +1,136 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class NamingAndCleanup1724396667634 implements MigrationInterface { + name = 'NamingAndCleanup1724396667634' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`member\` DROP FOREIGN KEY \`FK_de8e6856d6b77e1b2815a8c0d4f\``); + await queryRunner.query(`DROP INDEX \`IDX_73e1828d94de0b2ddf89da0546\` ON \`member\``); + await queryRunner.query(`DROP INDEX \`IDX_ab51d77cababfc4aa052344ec3\` ON \`member\``); + await queryRunner.query(`ALTER TABLE \`executive_position\` CHANGE \`number_of_performers\` \`numberOfPerformers\` int NOT NULL DEFAULT '-1'`); + await queryRunner.query(`CREATE TABLE \`communication_type\` (\`id\` int NOT NULL AUTO_INCREMENT, \`type\` varchar(255) NOT NULL, \`useColumns\` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`membership\` DROP COLUMN \`termination_reason\``); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` DROP COLUMN \`given\``); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` DROP COLUMN \`given\``); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` DROP COLUMN \`date\``); + await queryRunner.query(`ALTER TABLE \`communication\` DROP COLUMN \`type\``); + await queryRunner.query(`ALTER TABLE \`communication\` DROP COLUMN \`streetnumber_addition\``); + await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`member_id\``); + await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`deathdate\``); + await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`sepa_mandat\``); + await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`communicationsId\``); + await queryRunner.query(`ALTER TABLE \`membership\` ADD \`internalId\` varchar(255) NULL`); + await queryRunner.query(`ALTER TABLE \`membership\` ADD UNIQUE INDEX \`IDX_703f499fe3a9892e3a8790cdfc\` (\`internalId\`)`); + await queryRunner.query(`ALTER TABLE \`membership\` ADD \`terminationReason\` varchar(255) NULL`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` ADD \`start\` date NOT NULL`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` ADD \`end\` date NOT NULL`); + await queryRunner.query(`ALTER TABLE \`communication\` ADD \`streetnumberAddition\` varchar(255) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`communication\` ADD \`typeId\` int NULL`); + await queryRunner.query(`ALTER TABLE \`member\` ADD \`sepaMandat\` varchar(255) NULL`); + await queryRunner.query(`ALTER TABLE \`member\` ADD UNIQUE INDEX \`IDX_bb10fcac09c21d9666e147b8f6\` (\`sepaMandat\`)`); + await queryRunner.query(`ALTER TABLE \`member\` ADD \`sendNewsletterId\` int NULL`); + await queryRunner.query(`ALTER TABLE \`member\` ADD UNIQUE INDEX \`IDX_d57e160c4513cd949159217281\` (\`sendNewsletterId\`)`); + await queryRunner.query(`ALTER TABLE \`membership_status\` CHANGE \`status\` \`status\` varchar(255) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`membership\` DROP FOREIGN KEY \`FK_3b4b41597707b13086e71727422\``); + await queryRunner.query(`ALTER TABLE \`membership\` DROP FOREIGN KEY \`FK_e9fd4d37c4ac0fb08bd6eeeda3c\``); + await queryRunner.query(`ALTER TABLE \`membership\` CHANGE \`end\` \`end\` date NULL`); + await queryRunner.query(`ALTER TABLE \`membership\` CHANGE \`memberId\` \`memberId\` int NULL`); + await queryRunner.query(`ALTER TABLE \`membership\` CHANGE \`statusId\` \`statusId\` int NULL`); + await queryRunner.query(`ALTER TABLE \`qualification\` CHANGE \`description\` \`description\` varchar(255) NULL`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` DROP FOREIGN KEY \`FK_98b70e687c35709d2f01b3d7d74\``); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` DROP FOREIGN KEY \`FK_dbebe53df1caa0b6715a220b0ea\``); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` CHANGE \`note\` \`note\` varchar(255) NULL`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` CHANGE \`memberId\` \`memberId\` int NULL`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` CHANGE \`qualificationId\` \`qualificationId\` int NULL`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` DROP FOREIGN KEY \`FK_2912b056a5d0b7977360a986164\``); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` DROP FOREIGN KEY \`FK_1fd52c8f109123e5a2c67dc2c83\``); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` CHANGE \`note\` \`note\` varchar(255) NULL`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` CHANGE \`memberId\` \`memberId\` int NULL`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` CHANGE \`executivePositionId\` \`executivePositionId\` int NULL`); + await queryRunner.query(`ALTER TABLE \`communication\` DROP FOREIGN KEY \`FK_fc5f59e5c9aafdedd25ed8ed36e\``); + await queryRunner.query(`ALTER TABLE \`communication\` CHANGE \`memberId\` \`memberId\` int NULL`); + await queryRunner.query(`ALTER TABLE \`member_awards\` DROP FOREIGN KEY \`FK_a47e04bfd3671d8a375d1896d25\``); + await queryRunner.query(`ALTER TABLE \`member_awards\` DROP FOREIGN KEY \`FK_ba47b44c2ddf34c1bcc75df6675\``); + await queryRunner.query(`ALTER TABLE \`member_awards\` CHANGE \`note\` \`note\` varchar(255) NULL`); + await queryRunner.query(`ALTER TABLE \`member_awards\` CHANGE \`memberId\` \`memberId\` int NULL`); + await queryRunner.query(`ALTER TABLE \`member_awards\` CHANGE \`awardId\` \`awardId\` int NULL`); + await queryRunner.query(`CREATE UNIQUE INDEX \`REL_d57e160c4513cd949159217281\` ON \`member\` (\`sendNewsletterId\`)`); + await queryRunner.query(`ALTER TABLE \`membership\` ADD CONSTRAINT \`FK_3b4b41597707b13086e71727422\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`membership\` ADD CONSTRAINT \`FK_e9fd4d37c4ac0fb08bd6eeeda3c\` FOREIGN KEY (\`statusId\`) REFERENCES \`membership_status\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` ADD CONSTRAINT \`FK_98b70e687c35709d2f01b3d7d74\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` ADD CONSTRAINT \`FK_dbebe53df1caa0b6715a220b0ea\` FOREIGN KEY (\`qualificationId\`) REFERENCES \`qualification\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` ADD CONSTRAINT \`FK_2912b056a5d0b7977360a986164\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` ADD CONSTRAINT \`FK_1fd52c8f109123e5a2c67dc2c83\` FOREIGN KEY (\`executivePositionId\`) REFERENCES \`executive_position\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`communication\` ADD CONSTRAINT \`FK_21994db635b47e07f45b2686a51\` FOREIGN KEY (\`typeId\`) REFERENCES \`communication_type\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`communication\` ADD CONSTRAINT \`FK_fc5f59e5c9aafdedd25ed8ed36e\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member\` ADD CONSTRAINT \`FK_d57e160c4513cd9491592172814\` FOREIGN KEY (\`sendNewsletterId\`) REFERENCES \`communication\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_awards\` ADD CONSTRAINT \`FK_a47e04bfd3671d8a375d1896d25\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_awards\` ADD CONSTRAINT \`FK_ba47b44c2ddf34c1bcc75df6675\` FOREIGN KEY (\`awardId\`) REFERENCES \`award\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`member_awards\` DROP FOREIGN KEY \`FK_ba47b44c2ddf34c1bcc75df6675\``); + await queryRunner.query(`ALTER TABLE \`member_awards\` DROP FOREIGN KEY \`FK_a47e04bfd3671d8a375d1896d25\``); + await queryRunner.query(`ALTER TABLE \`member\` DROP FOREIGN KEY \`FK_d57e160c4513cd9491592172814\``); + await queryRunner.query(`ALTER TABLE \`communication\` DROP FOREIGN KEY \`FK_fc5f59e5c9aafdedd25ed8ed36e\``); + await queryRunner.query(`ALTER TABLE \`communication\` DROP FOREIGN KEY \`FK_21994db635b47e07f45b2686a51\``); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` DROP FOREIGN KEY \`FK_1fd52c8f109123e5a2c67dc2c83\``); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` DROP FOREIGN KEY \`FK_2912b056a5d0b7977360a986164\``); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` DROP FOREIGN KEY \`FK_dbebe53df1caa0b6715a220b0ea\``); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` DROP FOREIGN KEY \`FK_98b70e687c35709d2f01b3d7d74\``); + await queryRunner.query(`ALTER TABLE \`membership\` DROP FOREIGN KEY \`FK_e9fd4d37c4ac0fb08bd6eeeda3c\``); + await queryRunner.query(`ALTER TABLE \`membership\` DROP FOREIGN KEY \`FK_3b4b41597707b13086e71727422\``); + await queryRunner.query(`DROP INDEX \`REL_d57e160c4513cd949159217281\` ON \`member\``); + await queryRunner.query(`ALTER TABLE \`member_awards\` CHANGE \`awardId\` \`awardId\` int NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member_awards\` CHANGE \`memberId\` \`memberId\` int NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member_awards\` CHANGE \`note\` \`note\` varchar(255) NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member_awards\` ADD CONSTRAINT \`FK_ba47b44c2ddf34c1bcc75df6675\` FOREIGN KEY (\`awardId\`) REFERENCES \`award\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_awards\` ADD CONSTRAINT \`FK_a47e04bfd3671d8a375d1896d25\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`communication\` CHANGE \`memberId\` \`memberId\` int NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`communication\` ADD CONSTRAINT \`FK_fc5f59e5c9aafdedd25ed8ed36e\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` CHANGE \`executivePositionId\` \`executivePositionId\` int NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` CHANGE \`memberId\` \`memberId\` int NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` CHANGE \`note\` \`note\` varchar(255) NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` ADD CONSTRAINT \`FK_1fd52c8f109123e5a2c67dc2c83\` FOREIGN KEY (\`executivePositionId\`) REFERENCES \`executive_position\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` ADD CONSTRAINT \`FK_2912b056a5d0b7977360a986164\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` CHANGE \`qualificationId\` \`qualificationId\` int NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` CHANGE \`memberId\` \`memberId\` int NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` CHANGE \`note\` \`note\` varchar(255) NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` ADD CONSTRAINT \`FK_dbebe53df1caa0b6715a220b0ea\` FOREIGN KEY (\`qualificationId\`) REFERENCES \`qualification\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` ADD CONSTRAINT \`FK_98b70e687c35709d2f01b3d7d74\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE RESTRICT ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`qualification\` CHANGE \`description\` \`description\` varchar(255) NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`membership\` CHANGE \`statusId\` \`statusId\` int NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`membership\` CHANGE \`memberId\` \`memberId\` int NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`membership\` CHANGE \`end\` \`end\` date NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`membership\` ADD CONSTRAINT \`FK_e9fd4d37c4ac0fb08bd6eeeda3c\` FOREIGN KEY (\`statusId\`) REFERENCES \`membership_status\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`membership\` ADD CONSTRAINT \`FK_3b4b41597707b13086e71727422\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`membership_status\` CHANGE \`status\` \`status\` varchar(255) NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member\` DROP INDEX \`IDX_d57e160c4513cd949159217281\``); + await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`sendNewsletterId\``); + await queryRunner.query(`ALTER TABLE \`member\` DROP INDEX \`IDX_bb10fcac09c21d9666e147b8f6\``); + await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`sepaMandat\``); + await queryRunner.query(`ALTER TABLE \`communication\` DROP COLUMN \`typeId\``); + await queryRunner.query(`ALTER TABLE \`communication\` DROP COLUMN \`streetnumberAddition\``); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` DROP COLUMN \`end\``); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` DROP COLUMN \`start\``); + await queryRunner.query(`ALTER TABLE \`membership\` DROP COLUMN \`terminationReason\``); + await queryRunner.query(`ALTER TABLE \`membership\` DROP INDEX \`IDX_703f499fe3a9892e3a8790cdfc\``); + await queryRunner.query(`ALTER TABLE \`membership\` DROP COLUMN \`internalId\``); + await queryRunner.query(`ALTER TABLE \`member\` ADD \`communicationsId\` int NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member\` ADD \`sepa_mandat\` varchar(255) NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member\` ADD \`deathdate\` date NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`member\` ADD \`member_id\` varchar(255) NULL DEFAULT 'NULL'`); + await queryRunner.query(`ALTER TABLE \`communication\` ADD \`streetnumber_addition\` varchar(255) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`communication\` ADD \`type\` enum ('phone', 'mobile', 'address', 'mail', 'internalMail') NOT NULL DEFAULT ''phone''`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` ADD \`date\` date NOT NULL`); + await queryRunner.query(`ALTER TABLE \`member_executive_positions\` ADD \`given\` tinyint NOT NULL DEFAULT '1'`); + await queryRunner.query(`ALTER TABLE \`member_qualifications\` ADD \`given\` tinyint NOT NULL DEFAULT '1'`); + await queryRunner.query(`ALTER TABLE \`membership\` ADD \`termination_reason\` varchar(255) NULL DEFAULT 'NULL'`); + await queryRunner.query(`DROP TABLE \`communication_type\``); + await queryRunner.query(`ALTER TABLE \`executive_position\` CHANGE \`numberOfPerformers\` \`number_of_performers\` int NOT NULL DEFAULT '-1'`); + await queryRunner.query(`CREATE UNIQUE INDEX \`IDX_ab51d77cababfc4aa052344ec3\` ON \`member\` (\`sepa_mandat\`)`); + await queryRunner.query(`CREATE UNIQUE INDEX \`IDX_73e1828d94de0b2ddf89da0546\` ON \`member\` (\`member_id\`)`); + await queryRunner.query(`ALTER TABLE \`member\` ADD CONSTRAINT \`FK_de8e6856d6b77e1b2815a8c0d4f\` FOREIGN KEY (\`communicationsId\`) REFERENCES \`communication\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +}