server: add migration for movedTo user/notif

This commit is contained in:
Johann150 2022-11-20 22:05:16 +01:00
parent ac3e807717
commit abfba2699e
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -0,0 +1,19 @@
export class movedTo1668977715500 {
name = 'movedTo1668977715500';
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "user" ADD "movedToId" character varying(32)`);
await queryRunner.query(`ALTER TABLE "notification" ADD "moveTargetId" character varying(32)`);
await queryRunner.query(`COMMENT ON COLUMN "notification"."moveTargetId" IS 'The ID of the moved to account.'`);
await queryRunner.query(`ALTER TABLE "user" ADD CONSTRAINT "FK_16fef167e4253ccdc8971b01f6e" FOREIGN KEY ("movedToId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "notification" ADD CONSTRAINT "FK_078db271ad52ccc345b7b2b026a" FOREIGN KEY ("moveTargetId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "notification" DROP CONSTRAINT "FK_078db271ad52ccc345b7b2b026a"`);
await queryRunner.query(`ALTER TABLE "user" DROP CONSTRAINT "FK_16fef167e4253ccdc8971b01f6e"`);
await queryRunner.query(`COMMENT ON COLUMN "notification"."moveTargetId" IS 'The ID of the moved to account.'`);
await queryRunner.query(`ALTER TABLE "notification" DROP COLUMN "moveTargetId"`);
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "movedToId"`);
}
}