members-database/migrations/1724396667634-namingAndCleanup.ts

136 lines
16 KiB
TypeScript

import { MigrationInterface, QueryRunner } from "typeorm";
export class NamingAndCleanup1724396667634 implements MigrationInterface {
name = 'NamingAndCleanup1724396667634'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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`);
}
}