import { MigrationInterface, QueryRunner } from 'typeorm'; export class Refactoring1685871985306 implements MigrationInterface { name = 'Refactoring1685871985306'; public async up(queryRunner: QueryRunner): Promise { await queryRunner.query( `CREATE TABLE "group" ("id" int NOT NULL IDENTITY(1,1), "name" nvarchar(255) NOT NULL, CONSTRAINT "PK_256aa0fda9b1de1a73ee0b7106b" PRIMARY KEY ("id"))`, ); await queryRunner.query( `CREATE TABLE "person_groups_group" ("personId" int NOT NULL, "groupId" int NOT NULL, CONSTRAINT "PK_2ee7c7f82940eb58121d88a0176" PRIMARY KEY ("personId", "groupId"))`, ); await queryRunner.query( `CREATE INDEX "IDX_36e53832ea1beefb3de6cff976" ON "person_groups_group" ("personId") `, ); await queryRunner.query( `CREATE INDEX "IDX_267fc87e69a07e823de020a27e" ON "person_groups_group" ("groupId") `, ); await queryRunner.query( `ALTER TABLE "person_groups_group" ADD CONSTRAINT "FK_36e53832ea1beefb3de6cff976b" FOREIGN KEY ("personId") REFERENCES "person"("id") ON DELETE CASCADE ON UPDATE CASCADE`, ); await queryRunner.query( `ALTER TABLE "person_groups_group" ADD CONSTRAINT "FK_267fc87e69a07e823de020a27e7" FOREIGN KEY ("groupId") REFERENCES "group"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, ); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query( `ALTER TABLE "person_groups_group" DROP CONSTRAINT "FK_267fc87e69a07e823de020a27e7"`, ); await queryRunner.query( `ALTER TABLE "person_groups_group" DROP CONSTRAINT "FK_36e53832ea1beefb3de6cff976b"`, ); await queryRunner.query( `DROP INDEX "IDX_267fc87e69a07e823de020a27e" ON "person_groups_group"`, ); await queryRunner.query( `DROP INDEX "IDX_36e53832ea1beefb3de6cff976" ON "person_groups_group"`, ); await queryRunner.query(`DROP TABLE "person_groups_group"`); await queryRunner.query(`DROP TABLE "group"`); } }