From de9a6f28e5a06e2727bfa82c38b9f88fcd7bda02 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 13 Aug 2022 20:45:51 +0200 Subject: Do the funny thing (make user->invite cascade delet) --- .../postgres/1660416055566-InvitersAreDeletable.ts | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts (limited to 'util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts') diff --git a/util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts b/util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts new file mode 100644 index 00000000..e6101318 --- /dev/null +++ b/util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts @@ -0,0 +1,26 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class InvitersAreDeletable1660416055566 implements MigrationInterface { + name = 'InvitersAreDeletable1660416055566' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE "invites" DROP CONSTRAINT "FK_15c35422032e0b22b4ada95f48f" + `); + await queryRunner.query(` + ALTER TABLE "invites" + ADD CONSTRAINT "FK_15c35422032e0b22b4ada95f48f" FOREIGN KEY ("inviter_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION + `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE "invites" DROP CONSTRAINT "FK_15c35422032e0b22b4ada95f48f" + `); + await queryRunner.query(` + ALTER TABLE "invites" + ADD CONSTRAINT "FK_15c35422032e0b22b4ada95f48f" FOREIGN KEY ("inviter_id") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + +} -- cgit 1.5.1