FoundKey/packages/backend/migration/1668977715500-movedTo.js

20 lines
1.3 KiB
JavaScript

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"`);
}
}