Skip to content

Commit

Permalink
feat: update triggeredByIncidentId and triggeredByAlertId fields to b…
Browse files Browse the repository at this point in the history
…e nullable in relevant models
  • Loading branch information
simlarsen committed Jan 17, 2025
1 parent ad58125 commit af77d19
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default class OnCallDutyPolicyExecutionLogTimeline extends BaseModel {
})
@Column({
type: ColumnType.ObjectID,
nullable: false,
nullable: true,
transformer: ObjectID.getDatabaseTransformer(),
})
public triggeredByIncidentId?: ObjectID = undefined;
Expand Down Expand Up @@ -282,7 +282,7 @@ export default class OnCallDutyPolicyExecutionLogTimeline extends BaseModel {
})
@Column({
type: ColumnType.ObjectID,
nullable: false,
nullable: true,
transformer: ObjectID.getDatabaseTransformer(),
})
public triggeredByAlertId?: ObjectID = undefined;
Expand Down
4 changes: 2 additions & 2 deletions Common/Models/DatabaseModels/UserOnCallLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export default class UserOnCallLog extends BaseModel {
})
@Column({
type: ColumnType.ObjectID,
nullable: false,
nullable: true,
transformer: ObjectID.getDatabaseTransformer(),
})
public triggeredByIncidentId?: ObjectID = undefined;
Expand Down Expand Up @@ -421,7 +421,7 @@ export default class UserOnCallLog extends BaseModel {
})
@Column({
type: ColumnType.ObjectID,
nullable: false,
nullable: true,
transformer: ObjectID.getDatabaseTransformer(),
})
public triggeredByAlertId?: ObjectID = undefined;
Expand Down
4 changes: 2 additions & 2 deletions Common/Models/DatabaseModels/UserOnCallLogTimeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export default class UserOnCallLogTimeline extends BaseModel {
})
@Column({
type: ColumnType.ObjectID,
nullable: false,
nullable: true,
transformer: ObjectID.getDatabaseTransformer(),
})
public triggeredByIncidentId?: ObjectID = undefined;
Expand Down Expand Up @@ -381,7 +381,7 @@ export default class UserOnCallLogTimeline extends BaseModel {
})
@Column({
type: ColumnType.ObjectID,
nullable: false,
nullable: true,
transformer: ObjectID.getDatabaseTransformer(),
})
public triggeredByAlertId?: ObjectID = undefined;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class MigrationName1737141420441 implements MigrationInterface {
public name = 'MigrationName1737141420441'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ADD "triggeredByAlertId" uuid`);
await queryRunner.query(`ALTER TABLE "UserNotificationRule" ADD "alertSeverityId" uuid`);
await queryRunner.query(`ALTER TABLE "UserOnCallLog" ADD "triggeredByAlertId" uuid`);
await queryRunner.query(`ALTER TABLE "UserOnCallLogTimeline" ADD "triggeredByAlertId" uuid`);
await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" DROP CONSTRAINT "FK_90119ec7f77fa2efd82261e0448"`);
await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ALTER COLUMN "triggeredByIncidentId" DROP NOT NULL`);
await queryRunner.query(`ALTER TABLE "UserOnCallLog" DROP CONSTRAINT "FK_eeb0dd05d1dec542c3de5fb5074"`);
await queryRunner.query(`ALTER TABLE "UserOnCallLog" ALTER COLUMN "triggeredByIncidentId" DROP NOT NULL`);
await queryRunner.query(`ALTER TABLE "UserOnCallLogTimeline" DROP CONSTRAINT "FK_58a44736718a5ec4fe41526289a"`);
await queryRunner.query(`ALTER TABLE "UserOnCallLogTimeline" ALTER COLUMN "triggeredByIncidentId" DROP NOT NULL`);
await queryRunner.query(`CREATE INDEX "IDX_30358ab25e4c6c9ad72e74f201" ON "OnCallDutyPolicyExecutionLogTimeline" ("triggeredByAlertId") `);
await queryRunner.query(`CREATE INDEX "IDX_d73339f6c26fd6ebd0326badcd" ON "UserNotificationRule" ("alertSeverityId") `);
await queryRunner.query(`CREATE INDEX "IDX_42d9916277fcbefa0cdd3904c6" ON "UserOnCallLogTimeline" ("triggeredByAlertId") `);
await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ADD CONSTRAINT "FK_90119ec7f77fa2efd82261e0448" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ADD CONSTRAINT "FK_30358ab25e4c6c9ad72e74f201c" FOREIGN KEY ("triggeredByAlertId") REFERENCES "Alert"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "UserNotificationRule" ADD CONSTRAINT "FK_d73339f6c26fd6ebd0326badcd7" FOREIGN KEY ("alertSeverityId") REFERENCES "AlertSeverity"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "UserOnCallLog" ADD CONSTRAINT "FK_eeb0dd05d1dec542c3de5fb5074" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "UserOnCallLog" ADD CONSTRAINT "FK_0ee3711cdc64957845d9d028c31" FOREIGN KEY ("triggeredByAlertId") REFERENCES "Alert"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "UserOnCallLogTimeline" ADD CONSTRAINT "FK_58a44736718a5ec4fe41526289a" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "UserOnCallLogTimeline" ADD CONSTRAINT "FK_42d9916277fcbefa0cdd3904c63" FOREIGN KEY ("triggeredByAlertId") REFERENCES "Alert"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "UserOnCallLogTimeline" DROP CONSTRAINT "FK_42d9916277fcbefa0cdd3904c63"`);
await queryRunner.query(`ALTER TABLE "UserOnCallLogTimeline" DROP CONSTRAINT "FK_58a44736718a5ec4fe41526289a"`);
await queryRunner.query(`ALTER TABLE "UserOnCallLog" DROP CONSTRAINT "FK_0ee3711cdc64957845d9d028c31"`);
await queryRunner.query(`ALTER TABLE "UserOnCallLog" DROP CONSTRAINT "FK_eeb0dd05d1dec542c3de5fb5074"`);
await queryRunner.query(`ALTER TABLE "UserNotificationRule" DROP CONSTRAINT "FK_d73339f6c26fd6ebd0326badcd7"`);
await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" DROP CONSTRAINT "FK_30358ab25e4c6c9ad72e74f201c"`);
await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" DROP CONSTRAINT "FK_90119ec7f77fa2efd82261e0448"`);
await queryRunner.query(`DROP INDEX "public"."IDX_42d9916277fcbefa0cdd3904c6"`);
await queryRunner.query(`DROP INDEX "public"."IDX_d73339f6c26fd6ebd0326badcd"`);
await queryRunner.query(`DROP INDEX "public"."IDX_30358ab25e4c6c9ad72e74f201"`);
await queryRunner.query(`ALTER TABLE "UserOnCallLogTimeline" ALTER COLUMN "triggeredByIncidentId" SET NOT NULL`);
await queryRunner.query(`ALTER TABLE "UserOnCallLogTimeline" ADD CONSTRAINT "FK_58a44736718a5ec4fe41526289a" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "UserOnCallLog" ALTER COLUMN "triggeredByIncidentId" SET NOT NULL`);
await queryRunner.query(`ALTER TABLE "UserOnCallLog" ADD CONSTRAINT "FK_eeb0dd05d1dec542c3de5fb5074" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ALTER COLUMN "triggeredByIncidentId" SET NOT NULL`);
await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ADD CONSTRAINT "FK_90119ec7f77fa2efd82261e0448" FOREIGN KEY ("triggeredByIncidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "UserOnCallLogTimeline" DROP COLUMN "triggeredByAlertId"`);
await queryRunner.query(`ALTER TABLE "UserOnCallLog" DROP COLUMN "triggeredByAlertId"`);
await queryRunner.query(`ALTER TABLE "UserNotificationRule" DROP COLUMN "alertSeverityId"`);
await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" DROP COLUMN "triggeredByAlertId"`);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ import { MigrationName1736787495707 } from "./1736787495707-MigrationName";
import { MigrationName1736787985322 } from "./1736787985322-MigrationName";
import { MigrationName1736788706141 } from "./1736788706141-MigrationName";
import { MigrationName1736856662868 } from "./1736856662868-MigrationName";
import { MigrationName1737129427011 } from "./1737129427011-MigrationName";
import { MigrationName1737141420441 } from "./1737141420441-MigrationName";

export default [
InitialMigration,
Expand Down Expand Up @@ -195,5 +195,5 @@ export default [
MigrationName1736787985322,
MigrationName1736788706141,
MigrationName1736856662868,
MigrationName1737129427011
MigrationName1737141420441
];
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ObjectID from "../../Types/ObjectID";
import logger from "../Utils/Logger";
import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
import AlertFeedService from "./AlertFeedService";
import AlertFeed, { AlertFeedEventType } from "../../Models/DatabaseModels/AlertFeed";
import { AlertFeedEventType } from "../../Models/DatabaseModels/AlertFeed";

export class Service extends DatabaseService<Model> {
public constructor() {
Expand Down

0 comments on commit af77d19

Please sign in to comment.