diff --git a/Common/Models/DatabaseModels/StatusPage.ts b/Common/Models/DatabaseModels/StatusPage.ts index 4cbd1f2d85..4b49dfc26a 100755 --- a/Common/Models/DatabaseModels/StatusPage.ts +++ b/Common/Models/DatabaseModels/StatusPage.ts @@ -1312,7 +1312,7 @@ export default class StatusPage extends BaseModel { { eager: false, nullable: true, - onDelete: "CASCADE", + onDelete: "SET NULL", orphanedRowAction: "nullify", }, ) diff --git a/Common/Server/Infrastructure/Postgres/SchemaMigrations/1727104469670-MigrationName.ts b/Common/Server/Infrastructure/Postgres/SchemaMigrations/1727104469670-MigrationName.ts new file mode 100644 index 0000000000..a88ba80956 --- /dev/null +++ b/Common/Server/Infrastructure/Postgres/SchemaMigrations/1727104469670-MigrationName.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class MigrationName1727104469670 implements MigrationInterface { + public name = 'MigrationName1727104469670' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "StatusPage" DROP CONSTRAINT "FK_4e347d3f99b67dacd149beaf61d"`); + await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`); + await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`); + await queryRunner.query(`ALTER TABLE "StatusPage" ADD CONSTRAINT "FK_4e347d3f99b67dacd149beaf61d" FOREIGN KEY ("callSmsConfigId") REFERENCES "ProjectCallSMSConfig"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "StatusPage" DROP CONSTRAINT "FK_4e347d3f99b67dacd149beaf61d"`); + await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`); + await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`); + await queryRunner.query(`ALTER TABLE "StatusPage" ADD CONSTRAINT "FK_4e347d3f99b67dacd149beaf61d" FOREIGN KEY ("callSmsConfigId") REFERENCES "ProjectCallSMSConfig"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`); + } + +} diff --git a/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts b/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts index 0e310bedc4..9ed41af0c9 100644 --- a/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +++ b/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts @@ -65,6 +65,7 @@ import { MigrationName1727101782315 } from "./1727101782315-MigrationName"; import { MigrationName1727102156072 } from "./1727102156072-MigrationName"; import { MigrationName1727102331367 } from "./1727102331367-MigrationName"; import { MigrationName1727103023745 } from "./1727103023745-MigrationName"; +import { MigrationName1727104469670 } from "./1727104469670-MigrationName"; export default [ InitialMigration, @@ -134,4 +135,5 @@ export default [ MigrationName1727102156072, MigrationName1727102331367, MigrationName1727103023745, + MigrationName1727104469670 ];