@oneuptime/common 9.4.8 → 9.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.ts +59 -0
  2. package/Models/DatabaseModels/UserOnCallLog.ts +48 -0
  3. package/Models/DatabaseModels/UserOnCallLogTimeline.ts +49 -0
  4. package/Server/API/UserOnCallLogTimelineAPI.ts +65 -25
  5. package/Server/Infrastructure/Postgres/SchemaMigrations/1769469813786-MigrationName.ts +71 -0
  6. package/Server/Infrastructure/Postgres/SchemaMigrations/1769517677937-RenameNotificationRuleTypes.ts +67 -0
  7. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
  8. package/Server/Services/AlertEpisodeService.ts +134 -26
  9. package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +18 -1
  10. package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +64 -2
  11. package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +27 -1
  12. package/Server/Services/OnCallDutyPolicyService.ts +11 -1
  13. package/Server/Services/PushNotificationService.ts +1 -0
  14. package/Server/Services/UserNotificationRuleService.ts +641 -10
  15. package/Server/Services/UserOnCallLogService.ts +58 -14
  16. package/Server/Utils/PushNotificationUtil.ts +75 -16
  17. package/Types/Email/EmailTemplateType.ts +1 -0
  18. package/Types/NotificationRule/NotificationRuleType.ts +3 -2
  19. package/Types/WhatsApp/WhatsAppTemplates.ts +4 -0
  20. package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +1 -1
  21. package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +58 -0
  22. package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js.map +1 -1
  23. package/build/dist/Models/DatabaseModels/UserOnCallLog.js +47 -0
  24. package/build/dist/Models/DatabaseModels/UserOnCallLog.js.map +1 -1
  25. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +48 -0
  26. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
  27. package/build/dist/Server/API/UserOnCallLogTimelineAPI.js +55 -15
  28. package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
  29. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769469813786-MigrationName.js +30 -0
  30. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769469813786-MigrationName.js.map +1 -0
  31. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769517677937-RenameNotificationRuleTypes.js +67 -0
  32. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769517677937-RenameNotificationRuleTypes.js.map +1 -0
  33. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
  34. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  35. package/build/dist/Server/Services/AlertEpisodeService.js +111 -23
  36. package/build/dist/Server/Services/AlertEpisodeService.js.map +1 -1
  37. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +10 -1
  38. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
  39. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +49 -2
  40. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
  41. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +21 -1
  42. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
  43. package/build/dist/Server/Services/OnCallDutyPolicyService.js +6 -1
  44. package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
  45. package/build/dist/Server/Services/PushNotificationService.js.map +1 -1
  46. package/build/dist/Server/Services/UserNotificationRuleService.js +521 -43
  47. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  48. package/build/dist/Server/Services/UserOnCallLogService.js +48 -12
  49. package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
  50. package/build/dist/Server/Utils/PushNotificationUtil.js +51 -16
  51. package/build/dist/Server/Utils/PushNotificationUtil.js.map +1 -1
  52. package/build/dist/Types/Email/EmailTemplateType.js +1 -0
  53. package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
  54. package/build/dist/Types/NotificationRule/NotificationRuleType.js +3 -2
  55. package/build/dist/Types/NotificationRule/NotificationRuleType.js.map +1 -1
  56. package/build/dist/Types/WhatsApp/WhatsAppTemplates.js +3 -0
  57. package/build/dist/Types/WhatsApp/WhatsAppTemplates.js.map +1 -1
  58. package/package.json +1 -1
@@ -27,6 +27,7 @@ import Permission from "../../Types/Permission";
27
27
  import UserNotificationEventType from "../../Types/UserNotification/UserNotificationEventType";
28
28
  import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
29
29
  import Alert from "./Alert";
30
+ import AlertEpisode from "./AlertEpisode";
30
31
 
31
32
  @TableBillingAccessControl({
32
33
  create: PlanType.Growth,
@@ -288,6 +289,64 @@ export default class OnCallDutyPolicyExecutionLogTimeline extends BaseModel {
288
289
  })
289
290
  public triggeredByAlertId?: ObjectID = undefined;
290
291
 
292
+ @ColumnAccessControl({
293
+ create: [],
294
+ read: [
295
+ Permission.ProjectOwner,
296
+ Permission.ProjectAdmin,
297
+ Permission.ProjectMember,
298
+ Permission.ReadProjectOnCallDutyPolicyExecutionLogTimeline,
299
+ ],
300
+ update: [],
301
+ })
302
+ @TableColumn({
303
+ manyToOneRelationColumn: "triggeredByAlertEpisodeId",
304
+ type: TableColumnType.Entity,
305
+ modelType: AlertEpisode,
306
+ title: "Alert Episode",
307
+ description:
308
+ "Relation to Alert Episode Resource in which this object belongs",
309
+ })
310
+ @ManyToOne(
311
+ () => {
312
+ return AlertEpisode;
313
+ },
314
+ {
315
+ eager: false,
316
+ nullable: true,
317
+ onDelete: "CASCADE",
318
+ orphanedRowAction: "nullify",
319
+ },
320
+ )
321
+ @JoinColumn({ name: "triggeredByAlertEpisodeId" })
322
+ public triggeredByAlertEpisode?: AlertEpisode = undefined;
323
+
324
+ @ColumnAccessControl({
325
+ create: [],
326
+ read: [
327
+ Permission.ProjectOwner,
328
+ Permission.ProjectAdmin,
329
+ Permission.ProjectMember,
330
+ Permission.ReadProjectOnCallDutyPolicyExecutionLogTimeline,
331
+ ],
332
+ update: [],
333
+ })
334
+ @Index()
335
+ @TableColumn({
336
+ type: TableColumnType.ObjectID,
337
+ required: false,
338
+ canReadOnRelationQuery: true,
339
+ title: "Alert Episode ID",
340
+ description:
341
+ "ID of your OneUptime Alert Episode in which this object belongs",
342
+ })
343
+ @Column({
344
+ type: ColumnType.ObjectID,
345
+ nullable: true,
346
+ transformer: ObjectID.getDatabaseTransformer(),
347
+ })
348
+ public triggeredByAlertEpisodeId?: ObjectID = undefined;
349
+
291
350
  @ColumnAccessControl({
292
351
  create: [],
293
352
  read: [
@@ -28,6 +28,7 @@ import Permission from "../../Types/Permission";
28
28
  import UserNotificationEventType from "../../Types/UserNotification/UserNotificationEventType";
29
29
  import UserNotificationExecutionStatus from "../../Types/UserNotification/UserNotificationExecutionStatus";
30
30
  import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
31
+ import AlertEpisode from "./AlertEpisode";
31
32
  import Alert from "./Alert";
32
33
 
33
34
  @EnableDocumentation()
@@ -433,6 +434,53 @@ export default class UserOnCallLog extends BaseModel {
433
434
  })
434
435
  public triggeredByAlertId?: ObjectID = undefined;
435
436
 
437
+ @ColumnAccessControl({
438
+ create: [],
439
+ read: [Permission.CurrentUser],
440
+ update: [],
441
+ })
442
+ @TableColumn({
443
+ manyToOneRelationColumn: "triggeredByAlertEpisodeId",
444
+ type: TableColumnType.Entity,
445
+ modelType: AlertEpisode,
446
+ title: "Triggered By Alert Episode",
447
+ description:
448
+ "Relation to Alert Episode which triggered this on-call duty policy.",
449
+ })
450
+ @ManyToOne(
451
+ () => {
452
+ return AlertEpisode;
453
+ },
454
+ {
455
+ eager: false,
456
+ nullable: true,
457
+ onDelete: "CASCADE",
458
+ orphanedRowAction: "nullify",
459
+ },
460
+ )
461
+ @JoinColumn({ name: "triggeredByAlertEpisodeId" })
462
+ public triggeredByAlertEpisode?: AlertEpisode = undefined;
463
+
464
+ @ColumnAccessControl({
465
+ create: [],
466
+ read: [Permission.CurrentUser],
467
+ update: [],
468
+ })
469
+ @TableColumn({
470
+ type: TableColumnType.ObjectID,
471
+ title: "Triggered By Alert Episode ID",
472
+ required: false,
473
+ description:
474
+ "ID of the Alert Episode which triggered this on-call escalation policy.",
475
+ example: "3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f",
476
+ })
477
+ @Column({
478
+ type: ColumnType.ObjectID,
479
+ nullable: true,
480
+ transformer: ObjectID.getDatabaseTransformer(),
481
+ })
482
+ public triggeredByAlertEpisodeId?: ObjectID = undefined;
483
+
436
484
  @ColumnAccessControl({
437
485
  create: [],
438
486
  read: [Permission.CurrentUser],
@@ -1,5 +1,6 @@
1
1
  import Incident from "./Incident";
2
2
  import Alert from "./Alert";
3
+ import AlertEpisode from "./AlertEpisode";
3
4
  import OnCallDutyPolicy from "./OnCallDutyPolicy";
4
5
  import OnCallDutyPolicyEscalationRule from "./OnCallDutyPolicyEscalationRule";
5
6
  import OnCallDutyPolicyExecutionLog from "./OnCallDutyPolicyExecutionLog";
@@ -389,6 +390,54 @@ export default class UserOnCallLogTimeline extends BaseModel {
389
390
  })
390
391
  public triggeredByAlertId?: ObjectID = undefined;
391
392
 
393
+ @ColumnAccessControl({
394
+ create: [],
395
+ read: [Permission.CurrentUser],
396
+ update: [],
397
+ })
398
+ @TableColumn({
399
+ manyToOneRelationColumn: "triggeredByAlertEpisodeId",
400
+ type: TableColumnType.Entity,
401
+ modelType: AlertEpisode,
402
+ title: "Alert Episode",
403
+ description:
404
+ "Relation to Alert Episode Resource in which this object belongs",
405
+ })
406
+ @ManyToOne(
407
+ () => {
408
+ return AlertEpisode;
409
+ },
410
+ {
411
+ eager: false,
412
+ nullable: true,
413
+ onDelete: "CASCADE",
414
+ orphanedRowAction: "nullify",
415
+ },
416
+ )
417
+ @JoinColumn({ name: "triggeredByAlertEpisodeId" })
418
+ public triggeredByAlertEpisode?: AlertEpisode = undefined;
419
+
420
+ @ColumnAccessControl({
421
+ create: [],
422
+ read: [Permission.CurrentUser],
423
+ update: [],
424
+ })
425
+ @Index()
426
+ @TableColumn({
427
+ type: TableColumnType.ObjectID,
428
+ required: false,
429
+ canReadOnRelationQuery: true,
430
+ title: "Alert Episode ID",
431
+ description:
432
+ "ID of your OneUptime Alert Episode in which this object belongs",
433
+ })
434
+ @Column({
435
+ type: ColumnType.ObjectID,
436
+ nullable: true,
437
+ transformer: ObjectID.getDatabaseTransformer(),
438
+ })
439
+ public triggeredByAlertEpisodeId?: ObjectID = undefined;
440
+
392
441
  @ColumnAccessControl({
393
442
  create: [],
394
443
  read: [Permission.CurrentUser],
@@ -137,6 +137,11 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
137
137
  title: true,
138
138
  description: true,
139
139
  },
140
+ triggeredByAlertEpisodeId: true,
141
+ triggeredByAlertEpisode: {
142
+ title: true,
143
+ description: true,
144
+ },
140
145
  },
141
146
  props: {
142
147
  isRoot: true,
@@ -153,7 +158,15 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
153
158
 
154
159
  const notificationType: string = timelineItem.triggeredByIncidentId
155
160
  ? "Incident"
156
- : "Alert";
161
+ : timelineItem.triggeredByAlertEpisodeId
162
+ ? "Alert Episode"
163
+ : "Alert";
164
+
165
+ const notificationTitle: string =
166
+ timelineItem.triggeredByIncident?.title ||
167
+ timelineItem.triggeredByAlertEpisode?.title ||
168
+ timelineItem.triggeredByAlert?.title ||
169
+ "";
157
170
 
158
171
  const host: Hostname = await DatabaseConfig.getHost();
159
172
  const httpProtocol: Protocol = await DatabaseConfig.getHttpProtocol();
@@ -163,7 +176,7 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
163
176
  res,
164
177
  "/usr/src/Common/Server/Views/AcknowledgeUserOnCallNotification.ejs",
165
178
  {
166
- title: `Acknowledge ${notificationType} - ${timelineItem.triggeredByIncident?.title || timelineItem.triggeredByAlert?.title}`,
179
+ title: `Acknowledge ${notificationType} - ${notificationTitle}`,
167
180
  message: `Do you want to acknowledge this ${notificationType}?`,
168
181
  acknowledgeText: `Acknowledge ${notificationType}`,
169
182
  acknowledgeUrl: new URL(
@@ -208,12 +221,16 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
208
221
  projectId: true,
209
222
  triggeredByIncidentId: true,
210
223
  triggeredByAlertId: true,
224
+ triggeredByAlertEpisodeId: true,
211
225
  triggeredByAlert: {
212
226
  title: true,
213
227
  },
214
228
  triggeredByIncident: {
215
229
  title: true,
216
230
  },
231
+ triggeredByAlertEpisode: {
232
+ title: true,
233
+ },
217
234
  acknowledgedAt: true,
218
235
  isAcknowledged: true,
219
236
  },
@@ -233,13 +250,51 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
233
250
  const host: Hostname = await DatabaseConfig.getHost();
234
251
  const httpProtocol: Protocol = await DatabaseConfig.getHttpProtocol();
235
252
 
253
+ // Determine the resource type and ID for routing
254
+ type ResourceInfo = {
255
+ type: string;
256
+ path: string;
257
+ id: ObjectID;
258
+ title: string;
259
+ };
260
+
261
+ const getResourceInfo: () => ResourceInfo = (): ResourceInfo => {
262
+ if (timelineItem.triggeredByIncidentId) {
263
+ return {
264
+ type: "Incident",
265
+ path: "incidents",
266
+ id: timelineItem.triggeredByIncidentId,
267
+ title: timelineItem.triggeredByIncident?.title || "",
268
+ };
269
+ }
270
+ if (timelineItem.triggeredByAlertEpisodeId) {
271
+ return {
272
+ type: "Alert Episode",
273
+ path: "alert-episodes",
274
+ id: timelineItem.triggeredByAlertEpisodeId,
275
+ title: timelineItem.triggeredByAlertEpisode?.title || "",
276
+ };
277
+ }
278
+ if (timelineItem.triggeredByAlertId) {
279
+ return {
280
+ type: "Alert",
281
+ path: "alerts",
282
+ id: timelineItem.triggeredByAlertId,
283
+ title: timelineItem.triggeredByAlert?.title || "",
284
+ };
285
+ }
286
+ return { type: "", path: "", id: new ObjectID(""), title: "" };
287
+ };
288
+
289
+ const resourceInfo: ResourceInfo = getResourceInfo();
290
+
236
291
  if (timelineItem.isAcknowledged) {
237
292
  // already acknowledged. Then show already acknowledged page with view details button.
238
293
 
239
294
  const viewDetailsRoute: Route = new Route(
240
295
  DashboardRoute.toString(),
241
296
  ).addRoute(
242
- `/${timelineItem.projectId?.toString()}/${timelineItem.triggeredByIncidentId ? "incidents" : "alerts"}/${timelineItem.triggeredByIncidentId ? timelineItem.triggeredByIncidentId!.toString() : timelineItem.triggeredByAlertId!.toString()}`,
297
+ `/${timelineItem.projectId?.toString()}/${resourceInfo.path}/${resourceInfo.id.toString()}`,
243
298
  );
244
299
 
245
300
  const viewDetailsUrl: URL = new URL(
@@ -253,9 +308,9 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
253
308
  res,
254
309
  "/usr/src/Common/Server/Views/ViewMessage.ejs",
255
310
  {
256
- title: `Notification Already Acknowledged - ${timelineItem.triggeredByIncident?.title || timelineItem.triggeredByAlert?.title}`,
311
+ title: `Notification Already Acknowledged - ${resourceInfo.title}`,
257
312
  message: `This notification has already been acknowledged.`,
258
- viewDetailsText: `View ${timelineItem.triggeredByIncidentId ? "Incident" : "Alert"}`,
313
+ viewDetailsText: `View ${resourceInfo.type}`,
259
314
  viewDetailsUrl: viewDetailsUrl.toString(),
260
315
  },
261
316
  );
@@ -274,33 +329,18 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
274
329
  },
275
330
  });
276
331
 
277
- // redirect to dashboard to incidents page.
278
-
279
- if (timelineItem.triggeredByIncidentId) {
280
- const incidentRoute: Route = new Route(
281
- DashboardRoute.toString(),
282
- ).addRoute(
283
- `/${timelineItem.projectId?.toString()}/incidents/${timelineItem.triggeredByIncidentId!.toString()}`,
284
- );
285
-
286
- return Response.redirect(
287
- req,
288
- res,
289
- new URL(httpProtocol, host, incidentRoute),
290
- );
291
- }
292
-
293
- if (timelineItem.triggeredByAlertId) {
294
- const alertRoute: Route = new Route(
332
+ // redirect to dashboard to the resource page.
333
+ if (resourceInfo.path) {
334
+ const resourceRoute: Route = new Route(
295
335
  DashboardRoute.toString(),
296
336
  ).addRoute(
297
- `/${timelineItem.projectId?.toString()}/alerts/${timelineItem.triggeredByAlertId!.toString()}`,
337
+ `/${timelineItem.projectId?.toString()}/${resourceInfo.path}/${resourceInfo.id.toString()}`,
298
338
  );
299
339
 
300
340
  return Response.redirect(
301
341
  req,
302
342
  res,
303
- new URL(httpProtocol, host, alertRoute),
343
+ new URL(httpProtocol, host, resourceRoute),
304
344
  );
305
345
  }
306
346
 
@@ -0,0 +1,71 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1769469813786 implements MigrationInterface {
4
+ public name = "MigrationName1769469813786";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ADD "triggeredByAlertEpisodeId" uuid`,
9
+ );
10
+ await queryRunner.query(
11
+ `ALTER TABLE "UserOnCallLog" ADD "triggeredByAlertEpisodeId" uuid`,
12
+ );
13
+ await queryRunner.query(
14
+ `ALTER TABLE "UserOnCallLogTimeline" ADD "triggeredByAlertEpisodeId" uuid`,
15
+ );
16
+ await queryRunner.query(
17
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
21
+ );
22
+ await queryRunner.query(
23
+ `CREATE INDEX "IDX_1fda33fffd89b95dafa537f3be" ON "OnCallDutyPolicyExecutionLogTimeline" ("triggeredByAlertEpisodeId") `,
24
+ );
25
+ await queryRunner.query(
26
+ `CREATE INDEX "IDX_2c98f4eeddf1d00ec073b49352" ON "UserOnCallLogTimeline" ("triggeredByAlertEpisodeId") `,
27
+ );
28
+ await queryRunner.query(
29
+ `ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" ADD CONSTRAINT "FK_1fda33fffd89b95dafa537f3bef" FOREIGN KEY ("triggeredByAlertEpisodeId") REFERENCES "AlertEpisode"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
30
+ );
31
+ await queryRunner.query(
32
+ `ALTER TABLE "UserOnCallLog" ADD CONSTRAINT "FK_114aa962f2bc3c6736a1469df36" FOREIGN KEY ("triggeredByAlertEpisodeId") REFERENCES "AlertEpisode"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
33
+ );
34
+ await queryRunner.query(
35
+ `ALTER TABLE "UserOnCallLogTimeline" ADD CONSTRAINT "FK_2c98f4eeddf1d00ec073b493525" FOREIGN KEY ("triggeredByAlertEpisodeId") REFERENCES "AlertEpisode"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
36
+ );
37
+ }
38
+
39
+ public async down(queryRunner: QueryRunner): Promise<void> {
40
+ await queryRunner.query(
41
+ `ALTER TABLE "UserOnCallLogTimeline" DROP CONSTRAINT "FK_2c98f4eeddf1d00ec073b493525"`,
42
+ );
43
+ await queryRunner.query(
44
+ `ALTER TABLE "UserOnCallLog" DROP CONSTRAINT "FK_114aa962f2bc3c6736a1469df36"`,
45
+ );
46
+ await queryRunner.query(
47
+ `ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" DROP CONSTRAINT "FK_1fda33fffd89b95dafa537f3bef"`,
48
+ );
49
+ await queryRunner.query(
50
+ `DROP INDEX "public"."IDX_2c98f4eeddf1d00ec073b49352"`,
51
+ );
52
+ await queryRunner.query(
53
+ `DROP INDEX "public"."IDX_1fda33fffd89b95dafa537f3be"`,
54
+ );
55
+ await queryRunner.query(
56
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
57
+ );
58
+ await queryRunner.query(
59
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
60
+ );
61
+ await queryRunner.query(
62
+ `ALTER TABLE "UserOnCallLogTimeline" DROP COLUMN "triggeredByAlertEpisodeId"`,
63
+ );
64
+ await queryRunner.query(
65
+ `ALTER TABLE "UserOnCallLog" DROP COLUMN "triggeredByAlertEpisodeId"`,
66
+ );
67
+ await queryRunner.query(
68
+ `ALTER TABLE "OnCallDutyPolicyExecutionLogTimeline" DROP COLUMN "triggeredByAlertEpisodeId"`,
69
+ );
70
+ }
71
+ }
@@ -0,0 +1,67 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+ import CaptureSpan from "../../../Utils/Telemetry/CaptureSpan";
3
+
4
+ export class RenameNotificationRuleTypes1769517677937
5
+ implements MigrationInterface
6
+ {
7
+ public name = "RenameNotificationRuleTypes1769517677937";
8
+
9
+ @CaptureSpan()
10
+ public async up(queryRunner: QueryRunner): Promise<void> {
11
+ /*
12
+ * 1. Update rules with "When on-call policy is executed" and incidentSeverityId (not null)
13
+ * to "When incident on-call policy is executed"
14
+ */
15
+ await queryRunner.query(
16
+ `UPDATE "UserNotificationRule"
17
+ SET "ruleType" = 'When incident on-call policy is executed'
18
+ WHERE "ruleType" = 'When on-call policy is executed'
19
+ AND "incidentSeverityId" IS NOT NULL`,
20
+ );
21
+
22
+ /*
23
+ * 2. Update rules with "When on-call policy is executed" and alertSeverityId (not null)
24
+ * to "When alert on-call policy is executed"
25
+ */
26
+ await queryRunner.query(
27
+ `UPDATE "UserNotificationRule"
28
+ SET "ruleType" = 'When alert on-call policy is executed'
29
+ WHERE "ruleType" = 'When on-call policy is executed'
30
+ AND "alertSeverityId" IS NOT NULL`,
31
+ );
32
+
33
+ /*
34
+ * 3. Update rules with "When episode on-call policy is executed"
35
+ * to "When alert episode on-call policy is executed"
36
+ */
37
+ await queryRunner.query(
38
+ `UPDATE "UserNotificationRule"
39
+ SET "ruleType" = 'When alert episode on-call policy is executed'
40
+ WHERE "ruleType" = 'When episode on-call policy is executed'`,
41
+ );
42
+ }
43
+
44
+ @CaptureSpan()
45
+ public async down(queryRunner: QueryRunner): Promise<void> {
46
+ // Revert "When incident on-call policy is executed" back to "When on-call policy is executed"
47
+ await queryRunner.query(
48
+ `UPDATE "UserNotificationRule"
49
+ SET "ruleType" = 'When on-call policy is executed'
50
+ WHERE "ruleType" = 'When incident on-call policy is executed'`,
51
+ );
52
+
53
+ // Revert "When alert on-call policy is executed" back to "When on-call policy is executed"
54
+ await queryRunner.query(
55
+ `UPDATE "UserNotificationRule"
56
+ SET "ruleType" = 'When on-call policy is executed'
57
+ WHERE "ruleType" = 'When alert on-call policy is executed'`,
58
+ );
59
+
60
+ // Revert "When alert episode on-call policy is executed" back to "When episode on-call policy is executed"
61
+ await queryRunner.query(
62
+ `UPDATE "UserNotificationRule"
63
+ SET "ruleType" = 'When episode on-call policy is executed'
64
+ WHERE "ruleType" = 'When alert episode on-call policy is executed'`,
65
+ );
66
+ }
67
+ }
@@ -234,6 +234,8 @@ import { MigrationName1769199303656 } from "./1769199303656-MigrationName";
234
234
  import { MigrationName1769202898645 } from "./1769202898645-MigrationName";
235
235
  import { MigrationName1769428619414 } from "./1769428619414-MigrationName";
236
236
  import { MigrationName1769428821686 } from "./1769428821686-MigrationName";
237
+ import { MigrationName1769469813786 } from "./1769469813786-MigrationName";
238
+ import { RenameNotificationRuleTypes1769517677937 } from "./1769517677937-RenameNotificationRuleTypes";
237
239
 
238
240
  export default [
239
241
  InitialMigration,
@@ -472,4 +474,6 @@ export default [
472
474
  MigrationName1769202898645,
473
475
  MigrationName1769428619414,
474
476
  MigrationName1769428821686,
477
+ MigrationName1769469813786,
478
+ RenameNotificationRuleTypes1769517677937,
475
479
  ];