80 lines
8.6 KiB
TypeScript
80 lines
8.6 KiB
TypeScript
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||
|
|
||
|
export class SplitMember1724064152696 implements MigrationInterface {
|
||
|
name = 'SplitMember1724064152696'
|
||
|
|
||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||
|
await queryRunner.query(`ALTER TABLE \`qualification\` CHANGE \`number_of_performers\` \`description\` int NOT NULL DEFAULT '1'`);
|
||
|
await queryRunner.query(`CREATE TABLE \`city\` (\`id\` varchar(36) NOT NULL, \`postal_code\` varchar(255) NOT NULL, \`city\` varchar(255) NOT NULL, UNIQUE INDEX \`IDX_cc45d5049db48b8d7c0f9cf2b3\` (\`postal_code\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||
|
await queryRunner.query(`CREATE TABLE \`city_district\` (\`id\` varchar(36) NOT NULL, \`district\` varchar(255) NULL, \`cityId\` varchar(36) NULL, UNIQUE INDEX \`IDX_9c5511a4d64dda3dc96472db53\` (\`district\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||
|
await queryRunner.query(`CREATE TABLE \`membership\` (\`id\` varchar(36) NOT NULL, \`start\` date NOT NULL, \`end\` date NULL, \`type\` enum ('active', 'passive') NOT NULL DEFAULT 'active', \`reason\` varchar(255) NULL, \`memberId\` varchar(36) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||
|
await queryRunner.query(`CREATE TABLE \`award\` (\`id\` varchar(36) NOT NULL, \`award\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||
|
await queryRunner.query(`CREATE TABLE \`member_awards\` (\`memberId\` varchar(36) NOT NULL, \`awardId\` varchar(36) NOT NULL, \`given\` tinyint NOT NULL DEFAULT 1, \`reason\` varchar(255) NULL, \`date\` date NOT NULL, UNIQUE INDEX \`IDX_abbbec2c01332355aab3b811c0\` (\`memberId\`, \`awardId\`), PRIMARY KEY (\`memberId\`, \`awardId\`)) ENGINE=InnoDB`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`postal_code\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`place\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`accession_date\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`leaving_data\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`active\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`salutation\` enum ('sir', 'madam', 'other', 'none') NOT NULL DEFAULT 'none'`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`sepa_mandat\` varchar(255) NULL`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD UNIQUE INDEX \`IDX_ab51d77cababfc4aa052344ec3\` (\`sepa_mandat\`)`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`official_email\` varchar(255) NULL`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`deathdate\` date NULL`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`newsletter\` enum ('online', 'offline', 'none') NOT NULL DEFAULT 'online'`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`city\` varchar(36) NULL`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`district\` varchar(36) NULL`);
|
||
|
await queryRunner.query(`ALTER TABLE \`executive_position\` CHANGE \`number_of_performers\` \`number_of_performers\` int NOT NULL DEFAULT '-1'`);
|
||
|
await queryRunner.query(`ALTER TABLE \`qualification\` DROP COLUMN \`description\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`qualification\` ADD \`description\` varchar(255) NULL`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` CHANGE \`member_id\` \`member_id\` varchar(255) NULL`);
|
||
|
await queryRunner.query(`ALTER TABLE \`session\` DROP FOREIGN KEY \`FK_1f8d57f74fb4486a743d89d4820\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`session\` CHANGE \`memberId\` \`memberId\` varchar(36) NULL`);
|
||
|
await queryRunner.query(`ALTER TABLE \`city_district\` ADD CONSTRAINT \`FK_7193b3158b46421daeae4a62f95\` FOREIGN KEY (\`cityId\`) REFERENCES \`city\`(\`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 \`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`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD CONSTRAINT \`FK_cf71c62f17604b8c0e9c15c9556\` FOREIGN KEY (\`city\`) REFERENCES \`city\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD CONSTRAINT \`FK_e74f4be05ffd453b5dfb51d6f79\` FOREIGN KEY (\`district\`) REFERENCES \`city_district\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||
|
await queryRunner.query(`ALTER TABLE \`session\` ADD CONSTRAINT \`FK_1f8d57f74fb4486a743d89d4820\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||
|
}
|
||
|
|
||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||
|
await queryRunner.query(`ALTER TABLE \`session\` DROP FOREIGN KEY \`FK_1f8d57f74fb4486a743d89d4820\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP FOREIGN KEY \`FK_e74f4be05ffd453b5dfb51d6f79\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP FOREIGN KEY \`FK_cf71c62f17604b8c0e9c15c9556\``);
|
||
|
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 \`membership\` DROP FOREIGN KEY \`FK_3b4b41597707b13086e71727422\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`city_district\` DROP FOREIGN KEY \`FK_7193b3158b46421daeae4a62f95\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`session\` CHANGE \`memberId\` \`memberId\` varchar(36) NULL DEFAULT 'NULL'`);
|
||
|
await queryRunner.query(`ALTER TABLE \`session\` ADD CONSTRAINT \`FK_1f8d57f74fb4486a743d89d4820\` FOREIGN KEY (\`memberId\`) REFERENCES \`member\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` CHANGE \`member_id\` \`member_id\` varchar(255) NULL DEFAULT 'NULL'`);
|
||
|
await queryRunner.query(`ALTER TABLE \`qualification\` DROP COLUMN \`description\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`qualification\` ADD \`description\` int NOT NULL DEFAULT '1'`);
|
||
|
await queryRunner.query(`ALTER TABLE \`executive_position\` CHANGE \`number_of_performers\` \`number_of_performers\` int NOT NULL DEFAULT '1'`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`district\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`city\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`newsletter\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`deathdate\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`official_email\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP INDEX \`IDX_ab51d77cababfc4aa052344ec3\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`sepa_mandat\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` DROP COLUMN \`salutation\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`active\` tinyint NOT NULL DEFAULT '1'`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`leaving_data\` date NULL DEFAULT 'NULL'`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`accession_date\` date NOT NULL`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`place\` varchar(255) NOT NULL`);
|
||
|
await queryRunner.query(`ALTER TABLE \`member\` ADD \`postal_code\` varchar(255) NOT NULL`);
|
||
|
await queryRunner.query(`DROP INDEX \`IDX_abbbec2c01332355aab3b811c0\` ON \`member_awards\``);
|
||
|
await queryRunner.query(`DROP TABLE \`member_awards\``);
|
||
|
await queryRunner.query(`DROP TABLE \`award\``);
|
||
|
await queryRunner.query(`DROP TABLE \`membership\``);
|
||
|
await queryRunner.query(`DROP INDEX \`IDX_9c5511a4d64dda3dc96472db53\` ON \`city_district\``);
|
||
|
await queryRunner.query(`DROP TABLE \`city_district\``);
|
||
|
await queryRunner.query(`DROP INDEX \`IDX_cc45d5049db48b8d7c0f9cf2b3\` ON \`city\``);
|
||
|
await queryRunner.query(`DROP TABLE \`city\``);
|
||
|
await queryRunner.query(`ALTER TABLE \`qualification\` CHANGE \`description\` \`number_of_performers\` int NOT NULL DEFAULT '1'`);
|
||
|
}
|
||
|
|
||
|
}
|