From 0d471073eb9ed4b09c7de067f61230a637cd43a7 Mon Sep 17 00:00:00 2001 From: pratik Date: Mon, 9 Oct 2023 13:44:43 +0530 Subject: [PATCH] migration file for stratification factor status and remove cascade delete --- ...696829429134-stratificationFactorStatus.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 backend/packages/Upgrade/src/database/migrations/1696829429134-stratificationFactorStatus.ts diff --git a/backend/packages/Upgrade/src/database/migrations/1696829429134-stratificationFactorStatus.ts b/backend/packages/Upgrade/src/database/migrations/1696829429134-stratificationFactorStatus.ts new file mode 100644 index 0000000000..d5d5a90def --- /dev/null +++ b/backend/packages/Upgrade/src/database/migrations/1696829429134-stratificationFactorStatus.ts @@ -0,0 +1,20 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class stratificationFactorStatus1696829429134 implements MigrationInterface { + name = 'stratificationFactorStatus1696829429134' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "public"."user_stratification_factor" DROP CONSTRAINT "FK_a314482a152dd63f49898feb468"`); + await queryRunner.query(`ALTER TABLE "public"."experiment" DROP CONSTRAINT "FK_335189d91114f3a71ff18be6243"`); + await queryRunner.query(`ALTER TABLE "public"."user_stratification_factor" ADD CONSTRAINT "FK_a314482a152dd63f49898feb468" FOREIGN KEY ("userId") REFERENCES "experiment_user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "public"."experiment" ADD CONSTRAINT "FK_335189d91114f3a71ff18be6243" FOREIGN KEY ("stratificationFactorStratificationFactorName") REFERENCES "stratification_factor"("stratificationFactorName") ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "public"."experiment" DROP CONSTRAINT "FK_335189d91114f3a71ff18be6243"`); + await queryRunner.query(`ALTER TABLE "public"."user_stratification_factor" DROP CONSTRAINT "FK_a314482a152dd63f49898feb468"`); + await queryRunner.query(`ALTER TABLE "public"."experiment" ADD CONSTRAINT "FK_335189d91114f3a71ff18be6243" FOREIGN KEY ("stratificationFactorStratificationFactorName") REFERENCES "stratification_factor"("stratificationFactorName") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "public"."user_stratification_factor" ADD CONSTRAINT "FK_a314482a152dd63f49898feb468" FOREIGN KEY ("userId") REFERENCES "experiment_user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + } + +}