summary refs log tree commit diff
path: root/src/util/migrations/postgres/1660416055566-InvitersAreDeletable.ts
blob: e610131891d4def062310ab427b4bff3b3b941bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { MigrationInterface, QueryRunner } from "typeorm";

export class InvitersAreDeletable1660416055566 implements MigrationInterface {
    name = 'InvitersAreDeletable1660416055566'

    public async up(queryRunner: QueryRunner): Promise<void> {
        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<void> {
        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
        `);
    }

}