@oneuptime/common 10.0.30 → 10.0.33
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.
- package/Models/AnalyticsModels/ExceptionInstance.ts +29 -4
- package/Models/AnalyticsModels/Log.ts +110 -4
- package/Models/AnalyticsModels/Metric.ts +16 -9
- package/Models/AnalyticsModels/MonitorLog.ts +4 -2
- package/Models/AnalyticsModels/Span.ts +79 -6
- package/Models/DatabaseModels/Index.ts +8 -0
- package/Models/DatabaseModels/LogDropFilter.ts +480 -0
- package/Models/DatabaseModels/LogPipeline.ts +412 -0
- package/Models/DatabaseModels/LogPipelineProcessor.ts +430 -0
- package/Models/DatabaseModels/LogScrubRule.ts +516 -0
- package/Server/API/TelemetryAPI.ts +261 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1773402621107-MigrationName.ts +131 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1773414578773-MigrationName.ts +79 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1773500000000-MigrationName.ts +41 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1773676206197-MigrationName.ts +57 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
- package/Server/Services/AnalyticsDatabaseService.ts +61 -0
- package/Server/Services/LogAggregationService.ts +238 -1
- package/Server/Services/LogDropFilterService.ts +10 -0
- package/Server/Services/LogPipelineProcessorService.ts +10 -0
- package/Server/Services/LogPipelineService.ts +10 -0
- package/Server/Services/LogScrubRuleService.ts +10 -0
- package/Server/Services/TelemetryAttributeService.ts +4 -6
- package/Server/Utils/AnalyticsDatabase/Statement.ts +15 -1
- package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +126 -11
- package/Tests/Server/Services/LogAggregationService.test.ts +3 -2
- package/Types/AnalyticsDatabase/AnalyticsTableName.ts +9 -0
- package/Types/AnalyticsDatabase/TableColumnType.ts +4 -0
- package/Types/Date.ts +22 -0
- package/Types/Log/LogDropFilterAction.ts +6 -0
- package/Types/Log/LogPipelineProcessorType.ts +44 -0
- package/Types/Log/LogScrubAction.ts +7 -0
- package/Types/Log/LogScrubPatternType.ts +10 -0
- package/Types/Permission.ts +174 -0
- package/UI/Components/LogsViewer/LogsViewer.tsx +152 -4
- package/UI/Components/LogsViewer/components/KeyboardShortcutsHelp.tsx +92 -0
- package/UI/Components/LogsViewer/components/LogDetailsPanel.tsx +332 -117
- package/UI/Components/LogsViewer/components/LogSearchBar.tsx +294 -274
- package/UI/Components/LogsViewer/components/LogsAnalyticsView.tsx +513 -234
- package/UI/Components/LogsViewer/components/LogsFilterCard.tsx +37 -29
- package/UI/Components/LogsViewer/components/LogsTable.tsx +6 -1
- package/UI/Components/LogsViewer/components/LogsViewerToolbar.tsx +106 -0
- package/UI/Utils/LogExport.ts +160 -0
- package/build/dist/Models/AnalyticsModels/ExceptionInstance.js +28 -4
- package/build/dist/Models/AnalyticsModels/ExceptionInstance.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Log.js +97 -4
- package/build/dist/Models/AnalyticsModels/Log.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Metric.js +16 -9
- package/build/dist/Models/AnalyticsModels/Metric.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/MonitorLog.js +4 -2
- package/build/dist/Models/AnalyticsModels/MonitorLog.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Span.js +73 -6
- package/build/dist/Models/AnalyticsModels/Span.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +8 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/LogDropFilter.js +508 -0
- package/build/dist/Models/DatabaseModels/LogDropFilter.js.map +1 -0
- package/build/dist/Models/DatabaseModels/LogPipeline.js +438 -0
- package/build/dist/Models/DatabaseModels/LogPipeline.js.map +1 -0
- package/build/dist/Models/DatabaseModels/LogPipelineProcessor.js +452 -0
- package/build/dist/Models/DatabaseModels/LogPipelineProcessor.js.map +1 -0
- package/build/dist/Models/DatabaseModels/LogScrubRule.js +545 -0
- package/build/dist/Models/DatabaseModels/LogScrubRule.js.map +1 -0
- package/build/dist/Server/API/TelemetryAPI.js +155 -0
- package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1773402621107-MigrationName.js +52 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1773402621107-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1773414578773-MigrationName.js +34 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1773414578773-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1773500000000-MigrationName.js +22 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1773500000000-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1773676206197-MigrationName.js +26 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1773676206197-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +30 -0
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/LogAggregationService.js +188 -1
- package/build/dist/Server/Services/LogAggregationService.js.map +1 -1
- package/build/dist/Server/Services/LogDropFilterService.js +9 -0
- package/build/dist/Server/Services/LogDropFilterService.js.map +1 -0
- package/build/dist/Server/Services/LogPipelineProcessorService.js +9 -0
- package/build/dist/Server/Services/LogPipelineProcessorService.js.map +1 -0
- package/build/dist/Server/Services/LogPipelineService.js +9 -0
- package/build/dist/Server/Services/LogPipelineService.js.map +1 -0
- package/build/dist/Server/Services/LogScrubRuleService.js +9 -0
- package/build/dist/Server/Services/LogScrubRuleService.js.map +1 -0
- package/build/dist/Server/Services/TelemetryAttributeService.js +4 -6
- package/build/dist/Server/Services/TelemetryAttributeService.js.map +1 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js +13 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js.map +1 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +89 -2
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
- package/build/dist/Tests/Server/Services/LogAggregationService.test.js +3 -2
- package/build/dist/Tests/Server/Services/LogAggregationService.test.js.map +1 -1
- package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js +10 -0
- package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js.map +1 -0
- package/build/dist/Types/AnalyticsDatabase/TableColumnType.js +4 -0
- package/build/dist/Types/AnalyticsDatabase/TableColumnType.js.map +1 -1
- package/build/dist/Types/Date.js +16 -0
- package/build/dist/Types/Date.js.map +1 -1
- package/build/dist/Types/Log/LogDropFilterAction.js +7 -0
- package/build/dist/Types/Log/LogDropFilterAction.js.map +1 -0
- package/build/dist/Types/Log/LogPipelineProcessorType.js +9 -0
- package/build/dist/Types/Log/LogPipelineProcessorType.js.map +1 -0
- package/build/dist/Types/Log/LogScrubAction.js +8 -0
- package/build/dist/Types/Log/LogScrubAction.js.map +1 -0
- package/build/dist/Types/Log/LogScrubPatternType.js +11 -0
- package/build/dist/Types/Log/LogScrubPatternType.js.map +1 -0
- package/build/dist/Types/Permission.js +152 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js +124 -11
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/KeyboardShortcutsHelp.js +36 -0
- package/build/dist/UI/Components/LogsViewer/components/KeyboardShortcutsHelp.js.map +1 -0
- package/build/dist/UI/Components/LogsViewer/components/LogDetailsPanel.js +114 -4
- package/build/dist/UI/Components/LogsViewer/components/LogDetailsPanel.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogSearchBar.js +17 -5
- package/build/dist/UI/Components/LogsViewer/components/LogSearchBar.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsAnalyticsView.js +229 -122
- package/build/dist/UI/Components/LogsViewer/components/LogsAnalyticsView.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsFilterCard.js +5 -4
- package/build/dist/UI/Components/LogsViewer/components/LogsFilterCard.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsTable.js +4 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsTable.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsViewerToolbar.js +28 -0
- package/build/dist/UI/Components/LogsViewer/components/LogsViewerToolbar.js.map +1 -1
- package/build/dist/UI/Utils/LogExport.js +129 -0
- package/build/dist/UI/Utils/LogExport.js.map +1 -0
- package/package.json +1 -1
|
@@ -410,6 +410,267 @@ router.post(
|
|
|
410
410
|
},
|
|
411
411
|
);
|
|
412
412
|
|
|
413
|
+
// --- Log Export Endpoint ---
|
|
414
|
+
|
|
415
|
+
router.post(
|
|
416
|
+
"/telemetry/logs/export",
|
|
417
|
+
UserMiddleware.getUserMiddleware,
|
|
418
|
+
async (
|
|
419
|
+
req: ExpressRequest,
|
|
420
|
+
res: ExpressResponse,
|
|
421
|
+
next: NextFunction,
|
|
422
|
+
): Promise<void> => {
|
|
423
|
+
try {
|
|
424
|
+
const databaseProps: DatabaseCommonInteractionProps =
|
|
425
|
+
await CommonAPI.getDatabaseCommonInteractionProps(req);
|
|
426
|
+
|
|
427
|
+
if (!databaseProps?.tenantId) {
|
|
428
|
+
return Response.sendErrorResponse(
|
|
429
|
+
req,
|
|
430
|
+
res,
|
|
431
|
+
new BadDataException("Invalid Project ID"),
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const body: JSONObject = req.body as JSONObject;
|
|
436
|
+
|
|
437
|
+
const startTime: Date = body["startTime"]
|
|
438
|
+
? OneUptimeDate.fromString(body["startTime"] as string)
|
|
439
|
+
: OneUptimeDate.addRemoveHours(OneUptimeDate.getCurrentDate(), -1);
|
|
440
|
+
|
|
441
|
+
const endTime: Date = body["endTime"]
|
|
442
|
+
? OneUptimeDate.fromString(body["endTime"] as string)
|
|
443
|
+
: OneUptimeDate.getCurrentDate();
|
|
444
|
+
|
|
445
|
+
const limit: number = Math.min((body["limit"] as number) || 10000, 10000);
|
|
446
|
+
|
|
447
|
+
const format: string = (body["format"] as string) || "json";
|
|
448
|
+
|
|
449
|
+
const serviceIds: Array<ObjectID> | undefined = body["serviceIds"]
|
|
450
|
+
? (body["serviceIds"] as Array<string>).map((id: string) => {
|
|
451
|
+
return new ObjectID(id);
|
|
452
|
+
})
|
|
453
|
+
: undefined;
|
|
454
|
+
|
|
455
|
+
const severityTexts: Array<string> | undefined = body["severityTexts"]
|
|
456
|
+
? (body["severityTexts"] as Array<string>)
|
|
457
|
+
: undefined;
|
|
458
|
+
|
|
459
|
+
const bodySearchText: string | undefined = body["bodySearchText"]
|
|
460
|
+
? (body["bodySearchText"] as string)
|
|
461
|
+
: undefined;
|
|
462
|
+
|
|
463
|
+
const traceIds: Array<string> | undefined = body["traceIds"]
|
|
464
|
+
? (body["traceIds"] as Array<string>)
|
|
465
|
+
: undefined;
|
|
466
|
+
|
|
467
|
+
const spanIds: Array<string> | undefined = body["spanIds"]
|
|
468
|
+
? (body["spanIds"] as Array<string>)
|
|
469
|
+
: undefined;
|
|
470
|
+
|
|
471
|
+
const rows: Array<JSONObject> = await LogAggregationService.getExportLogs(
|
|
472
|
+
{
|
|
473
|
+
projectId: databaseProps.tenantId,
|
|
474
|
+
startTime,
|
|
475
|
+
endTime,
|
|
476
|
+
limit,
|
|
477
|
+
serviceIds,
|
|
478
|
+
severityTexts,
|
|
479
|
+
bodySearchText,
|
|
480
|
+
traceIds,
|
|
481
|
+
spanIds,
|
|
482
|
+
},
|
|
483
|
+
);
|
|
484
|
+
|
|
485
|
+
if (format === "csv") {
|
|
486
|
+
const header: string =
|
|
487
|
+
"time,serviceId,severityText,severityNumber,body,traceId,spanId,attributes";
|
|
488
|
+
const csvRows: Array<string> = rows.map((row: JSONObject) => {
|
|
489
|
+
const escapeCsv: (val: unknown) => string = (
|
|
490
|
+
val: unknown,
|
|
491
|
+
): string => {
|
|
492
|
+
const str: string =
|
|
493
|
+
val === null || val === undefined ? "" : String(val);
|
|
494
|
+
if (str.includes(",") || str.includes('"') || str.includes("\n")) {
|
|
495
|
+
return `"${str.replace(/"/g, '""')}"`;
|
|
496
|
+
}
|
|
497
|
+
return str;
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
return [
|
|
501
|
+
escapeCsv(row["time"]),
|
|
502
|
+
escapeCsv(row["serviceId"]),
|
|
503
|
+
escapeCsv(row["severityText"]),
|
|
504
|
+
escapeCsv(row["severityNumber"]),
|
|
505
|
+
escapeCsv(row["body"]),
|
|
506
|
+
escapeCsv(row["traceId"]),
|
|
507
|
+
escapeCsv(row["spanId"]),
|
|
508
|
+
escapeCsv(JSON.stringify(row["attributes"] || {})),
|
|
509
|
+
].join(",");
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
const csv: string = [header, ...csvRows].join("\n");
|
|
513
|
+
res.setHeader("Content-Type", "text/csv; charset=utf-8");
|
|
514
|
+
res.setHeader(
|
|
515
|
+
"Content-Disposition",
|
|
516
|
+
"attachment; filename=logs-export.csv",
|
|
517
|
+
);
|
|
518
|
+
res.status(200).send(csv);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// JSON format
|
|
523
|
+
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
524
|
+
res.setHeader(
|
|
525
|
+
"Content-Disposition",
|
|
526
|
+
"attachment; filename=logs-export.json",
|
|
527
|
+
);
|
|
528
|
+
res.status(200).send(JSON.stringify(rows, null, 2));
|
|
529
|
+
} catch (err: unknown) {
|
|
530
|
+
next(err);
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
);
|
|
534
|
+
|
|
535
|
+
// --- Log Context Endpoint ---
|
|
536
|
+
|
|
537
|
+
router.post(
|
|
538
|
+
"/telemetry/logs/context",
|
|
539
|
+
UserMiddleware.getUserMiddleware,
|
|
540
|
+
async (
|
|
541
|
+
req: ExpressRequest,
|
|
542
|
+
res: ExpressResponse,
|
|
543
|
+
next: NextFunction,
|
|
544
|
+
): Promise<void> => {
|
|
545
|
+
try {
|
|
546
|
+
const databaseProps: DatabaseCommonInteractionProps =
|
|
547
|
+
await CommonAPI.getDatabaseCommonInteractionProps(req);
|
|
548
|
+
|
|
549
|
+
if (!databaseProps?.tenantId) {
|
|
550
|
+
return Response.sendErrorResponse(
|
|
551
|
+
req,
|
|
552
|
+
res,
|
|
553
|
+
new BadDataException("Invalid Project ID"),
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const body: JSONObject = req.body as JSONObject;
|
|
558
|
+
|
|
559
|
+
const logId: string | undefined = body["logId"] as string | undefined;
|
|
560
|
+
const serviceId: string | undefined = body["serviceId"] as
|
|
561
|
+
| string
|
|
562
|
+
| undefined;
|
|
563
|
+
const time: string | undefined = body["time"] as string | undefined;
|
|
564
|
+
|
|
565
|
+
if (!logId || !serviceId || !time) {
|
|
566
|
+
return Response.sendErrorResponse(
|
|
567
|
+
req,
|
|
568
|
+
res,
|
|
569
|
+
new BadDataException("logId, serviceId, and time are required"),
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
const count: number = (body["count"] as number) || 5;
|
|
574
|
+
|
|
575
|
+
const result: {
|
|
576
|
+
before: Array<JSONObject>;
|
|
577
|
+
after: Array<JSONObject>;
|
|
578
|
+
} = await LogAggregationService.getLogContext({
|
|
579
|
+
projectId: databaseProps.tenantId,
|
|
580
|
+
serviceId: new ObjectID(serviceId),
|
|
581
|
+
time: OneUptimeDate.fromString(time),
|
|
582
|
+
logId,
|
|
583
|
+
count,
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
return Response.sendJsonObjectResponse(req, res, {
|
|
587
|
+
before: result.before as unknown as JSONObject,
|
|
588
|
+
after: result.after as unknown as JSONObject,
|
|
589
|
+
});
|
|
590
|
+
} catch (err: unknown) {
|
|
591
|
+
next(err);
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
// --- Drop Filter Estimate Endpoint ---
|
|
597
|
+
|
|
598
|
+
router.post(
|
|
599
|
+
"/telemetry/logs/drop-filter-estimate",
|
|
600
|
+
UserMiddleware.getUserMiddleware,
|
|
601
|
+
async (
|
|
602
|
+
req: ExpressRequest,
|
|
603
|
+
res: ExpressResponse,
|
|
604
|
+
next: NextFunction,
|
|
605
|
+
): Promise<void> => {
|
|
606
|
+
try {
|
|
607
|
+
const databaseProps: DatabaseCommonInteractionProps =
|
|
608
|
+
await CommonAPI.getDatabaseCommonInteractionProps(req);
|
|
609
|
+
|
|
610
|
+
if (!databaseProps?.tenantId) {
|
|
611
|
+
return Response.sendErrorResponse(
|
|
612
|
+
req,
|
|
613
|
+
res,
|
|
614
|
+
new BadDataException("Invalid Project ID"),
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
const body: JSONObject = req.body as JSONObject;
|
|
619
|
+
|
|
620
|
+
const filterQuery: string | undefined = body["filterQuery"] as
|
|
621
|
+
| string
|
|
622
|
+
| undefined;
|
|
623
|
+
|
|
624
|
+
if (!filterQuery) {
|
|
625
|
+
return Response.sendErrorResponse(
|
|
626
|
+
req,
|
|
627
|
+
res,
|
|
628
|
+
new BadDataException("filterQuery is required"),
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const startTime: Date = body["startTime"]
|
|
633
|
+
? OneUptimeDate.fromString(body["startTime"] as string)
|
|
634
|
+
: OneUptimeDate.addRemoveHours(OneUptimeDate.getCurrentDate(), -24);
|
|
635
|
+
|
|
636
|
+
const endTime: Date = body["endTime"]
|
|
637
|
+
? OneUptimeDate.fromString(body["endTime"] as string)
|
|
638
|
+
: OneUptimeDate.getCurrentDate();
|
|
639
|
+
|
|
640
|
+
const serviceIds: Array<ObjectID> | undefined = body["serviceIds"]
|
|
641
|
+
? (body["serviceIds"] as Array<string>).map((id: string) => {
|
|
642
|
+
return new ObjectID(id);
|
|
643
|
+
})
|
|
644
|
+
: undefined;
|
|
645
|
+
|
|
646
|
+
const severityTexts: Array<string> | undefined = body["severityTexts"]
|
|
647
|
+
? (body["severityTexts"] as Array<string>)
|
|
648
|
+
: undefined;
|
|
649
|
+
|
|
650
|
+
const result: {
|
|
651
|
+
totalLogs: number;
|
|
652
|
+
matchingLogs: number;
|
|
653
|
+
estimatedReductionPercent: number;
|
|
654
|
+
} = await LogAggregationService.getDropFilterEstimate({
|
|
655
|
+
projectId: databaseProps.tenantId,
|
|
656
|
+
startTime,
|
|
657
|
+
endTime,
|
|
658
|
+
filterQuery,
|
|
659
|
+
serviceIds,
|
|
660
|
+
severityTexts,
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
return Response.sendJsonObjectResponse(req, res, {
|
|
664
|
+
totalLogs: result.totalLogs,
|
|
665
|
+
matchingLogs: result.matchingLogs,
|
|
666
|
+
estimatedReductionPercent: result.estimatedReductionPercent,
|
|
667
|
+
} as unknown as JSONObject);
|
|
668
|
+
} catch (err: unknown) {
|
|
669
|
+
next(err);
|
|
670
|
+
}
|
|
671
|
+
},
|
|
672
|
+
);
|
|
673
|
+
|
|
413
674
|
// --- Helpers ---
|
|
414
675
|
|
|
415
676
|
function computeDefaultBucketSize(startTime: Date, endTime: Date): number {
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1773402621107 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1773402621107";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "LogPipeline" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "name" character varying(50) NOT NULL, "description" character varying(500), "filterQuery" character varying(500), "isEnabled" boolean NOT NULL DEFAULT true, "sortOrder" integer NOT NULL DEFAULT '0', "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_563f923c5169ef1e28c09dfa586" PRIMARY KEY ("_id"))`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`CREATE INDEX "IDX_a6bff623cedf515ae3680d8735" ON "LogPipeline" ("projectId") `,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`CREATE INDEX "IDX_70fc1c15d7770bf0646001b907" ON "LogPipeline" ("isEnabled") `,
|
|
15
|
+
);
|
|
16
|
+
await queryRunner.query(
|
|
17
|
+
`CREATE TABLE "LogPipelineProcessor" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "logPipelineId" uuid NOT NULL, "name" character varying(50) NOT NULL, "processorType" character varying(100) NOT NULL, "configuration" jsonb NOT NULL DEFAULT '{}', "isEnabled" boolean NOT NULL DEFAULT true, "sortOrder" integer NOT NULL DEFAULT '0', "createdByUserId" uuid, CONSTRAINT "PK_1f78f02415229abb3ff3fa0805a" PRIMARY KEY ("_id"))`,
|
|
18
|
+
);
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`CREATE INDEX "IDX_6236eaae19a7b0ffb57b6d8b05" ON "LogPipelineProcessor" ("projectId") `,
|
|
21
|
+
);
|
|
22
|
+
await queryRunner.query(
|
|
23
|
+
`CREATE INDEX "IDX_b6281d545398353d360a05d10c" ON "LogPipelineProcessor" ("logPipelineId") `,
|
|
24
|
+
);
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`CREATE INDEX "IDX_e7194996a6547d4557a26739d6" ON "LogPipelineProcessor" ("isEnabled") `,
|
|
27
|
+
);
|
|
28
|
+
await queryRunner.query(
|
|
29
|
+
`CREATE TABLE "LogDropFilter" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "name" character varying(50) NOT NULL, "description" character varying(500), "filterQuery" character varying(500) NOT NULL, "action" character varying(100) NOT NULL DEFAULT 'drop', "samplePercentage" integer, "isEnabled" boolean NOT NULL DEFAULT true, "sortOrder" integer NOT NULL DEFAULT '0', "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_4d5244c285955b534cbeb55b330" PRIMARY KEY ("_id"))`,
|
|
30
|
+
);
|
|
31
|
+
await queryRunner.query(
|
|
32
|
+
`CREATE INDEX "IDX_2651bf0f1b0981f3c1a15201fd" ON "LogDropFilter" ("projectId") `,
|
|
33
|
+
);
|
|
34
|
+
await queryRunner.query(
|
|
35
|
+
`CREATE INDEX "IDX_95cd1d1be21a2d7f620698ac48" ON "LogDropFilter" ("isEnabled") `,
|
|
36
|
+
);
|
|
37
|
+
await queryRunner.query(
|
|
38
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
|
|
39
|
+
);
|
|
40
|
+
await queryRunner.query(
|
|
41
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
|
|
42
|
+
);
|
|
43
|
+
await queryRunner.query(
|
|
44
|
+
`ALTER TABLE "LogPipeline" ADD CONSTRAINT "FK_a6bff623cedf515ae3680d87355" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
45
|
+
);
|
|
46
|
+
await queryRunner.query(
|
|
47
|
+
`ALTER TABLE "LogPipeline" ADD CONSTRAINT "FK_460794d1df27630235f2d543ba6" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
48
|
+
);
|
|
49
|
+
await queryRunner.query(
|
|
50
|
+
`ALTER TABLE "LogPipeline" ADD CONSTRAINT "FK_ffe95c5c8cbcea614d33c255d24" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
51
|
+
);
|
|
52
|
+
await queryRunner.query(
|
|
53
|
+
`ALTER TABLE "LogPipelineProcessor" ADD CONSTRAINT "FK_6236eaae19a7b0ffb57b6d8b053" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
54
|
+
);
|
|
55
|
+
await queryRunner.query(
|
|
56
|
+
`ALTER TABLE "LogPipelineProcessor" ADD CONSTRAINT "FK_b6281d545398353d360a05d10ce" FOREIGN KEY ("logPipelineId") REFERENCES "LogPipeline"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
57
|
+
);
|
|
58
|
+
await queryRunner.query(
|
|
59
|
+
`ALTER TABLE "LogPipelineProcessor" ADD CONSTRAINT "FK_b2e03f9db1555a4f5ff6bc7778c" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
60
|
+
);
|
|
61
|
+
await queryRunner.query(
|
|
62
|
+
`ALTER TABLE "LogDropFilter" ADD CONSTRAINT "FK_2651bf0f1b0981f3c1a15201fd7" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
63
|
+
);
|
|
64
|
+
await queryRunner.query(
|
|
65
|
+
`ALTER TABLE "LogDropFilter" ADD CONSTRAINT "FK_b613c2da8abed05bb4d1a94a277" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
66
|
+
);
|
|
67
|
+
await queryRunner.query(
|
|
68
|
+
`ALTER TABLE "LogDropFilter" ADD CONSTRAINT "FK_7702956f8707c3d3525ddb299c9" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
73
|
+
await queryRunner.query(
|
|
74
|
+
`ALTER TABLE "LogDropFilter" DROP CONSTRAINT "FK_7702956f8707c3d3525ddb299c9"`,
|
|
75
|
+
);
|
|
76
|
+
await queryRunner.query(
|
|
77
|
+
`ALTER TABLE "LogDropFilter" DROP CONSTRAINT "FK_b613c2da8abed05bb4d1a94a277"`,
|
|
78
|
+
);
|
|
79
|
+
await queryRunner.query(
|
|
80
|
+
`ALTER TABLE "LogDropFilter" DROP CONSTRAINT "FK_2651bf0f1b0981f3c1a15201fd7"`,
|
|
81
|
+
);
|
|
82
|
+
await queryRunner.query(
|
|
83
|
+
`ALTER TABLE "LogPipelineProcessor" DROP CONSTRAINT "FK_b2e03f9db1555a4f5ff6bc7778c"`,
|
|
84
|
+
);
|
|
85
|
+
await queryRunner.query(
|
|
86
|
+
`ALTER TABLE "LogPipelineProcessor" DROP CONSTRAINT "FK_b6281d545398353d360a05d10ce"`,
|
|
87
|
+
);
|
|
88
|
+
await queryRunner.query(
|
|
89
|
+
`ALTER TABLE "LogPipelineProcessor" DROP CONSTRAINT "FK_6236eaae19a7b0ffb57b6d8b053"`,
|
|
90
|
+
);
|
|
91
|
+
await queryRunner.query(
|
|
92
|
+
`ALTER TABLE "LogPipeline" DROP CONSTRAINT "FK_ffe95c5c8cbcea614d33c255d24"`,
|
|
93
|
+
);
|
|
94
|
+
await queryRunner.query(
|
|
95
|
+
`ALTER TABLE "LogPipeline" DROP CONSTRAINT "FK_460794d1df27630235f2d543ba6"`,
|
|
96
|
+
);
|
|
97
|
+
await queryRunner.query(
|
|
98
|
+
`ALTER TABLE "LogPipeline" DROP CONSTRAINT "FK_a6bff623cedf515ae3680d87355"`,
|
|
99
|
+
);
|
|
100
|
+
await queryRunner.query(
|
|
101
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
|
|
102
|
+
);
|
|
103
|
+
await queryRunner.query(
|
|
104
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
|
|
105
|
+
);
|
|
106
|
+
await queryRunner.query(
|
|
107
|
+
`DROP INDEX "public"."IDX_95cd1d1be21a2d7f620698ac48"`,
|
|
108
|
+
);
|
|
109
|
+
await queryRunner.query(
|
|
110
|
+
`DROP INDEX "public"."IDX_2651bf0f1b0981f3c1a15201fd"`,
|
|
111
|
+
);
|
|
112
|
+
await queryRunner.query(`DROP TABLE "LogDropFilter"`);
|
|
113
|
+
await queryRunner.query(
|
|
114
|
+
`DROP INDEX "public"."IDX_e7194996a6547d4557a26739d6"`,
|
|
115
|
+
);
|
|
116
|
+
await queryRunner.query(
|
|
117
|
+
`DROP INDEX "public"."IDX_b6281d545398353d360a05d10c"`,
|
|
118
|
+
);
|
|
119
|
+
await queryRunner.query(
|
|
120
|
+
`DROP INDEX "public"."IDX_6236eaae19a7b0ffb57b6d8b05"`,
|
|
121
|
+
);
|
|
122
|
+
await queryRunner.query(`DROP TABLE "LogPipelineProcessor"`);
|
|
123
|
+
await queryRunner.query(
|
|
124
|
+
`DROP INDEX "public"."IDX_70fc1c15d7770bf0646001b907"`,
|
|
125
|
+
);
|
|
126
|
+
await queryRunner.query(
|
|
127
|
+
`DROP INDEX "public"."IDX_a6bff623cedf515ae3680d8735"`,
|
|
128
|
+
);
|
|
129
|
+
await queryRunner.query(`DROP TABLE "LogPipeline"`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1773414578773 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1773414578773";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_logscrub_projectId"`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_logscrub_createdByUserId"`,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_logscrub_deletedByUserId"`,
|
|
15
|
+
);
|
|
16
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_logscrub_projectId"`);
|
|
17
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_logscrub_isEnabled"`);
|
|
18
|
+
await queryRunner.query(
|
|
19
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
|
|
20
|
+
);
|
|
21
|
+
await queryRunner.query(
|
|
22
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
|
|
23
|
+
);
|
|
24
|
+
await queryRunner.query(
|
|
25
|
+
`CREATE INDEX "IDX_0ed4595b431ba465ac9a9938d4" ON "LogScrubRule" ("projectId") `,
|
|
26
|
+
);
|
|
27
|
+
await queryRunner.query(
|
|
28
|
+
`CREATE INDEX "IDX_88d1e2bb9908f0aada30f044f5" ON "LogScrubRule" ("isEnabled") `,
|
|
29
|
+
);
|
|
30
|
+
await queryRunner.query(
|
|
31
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_0ed4595b431ba465ac9a9938d4d" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
32
|
+
);
|
|
33
|
+
await queryRunner.query(
|
|
34
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_cec04acd064a11bf98c2eae3819" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
35
|
+
);
|
|
36
|
+
await queryRunner.query(
|
|
37
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_88ad7031d2481dd8142e543ddbd" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
42
|
+
await queryRunner.query(
|
|
43
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_88ad7031d2481dd8142e543ddbd"`,
|
|
44
|
+
);
|
|
45
|
+
await queryRunner.query(
|
|
46
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_cec04acd064a11bf98c2eae3819"`,
|
|
47
|
+
);
|
|
48
|
+
await queryRunner.query(
|
|
49
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_0ed4595b431ba465ac9a9938d4d"`,
|
|
50
|
+
);
|
|
51
|
+
await queryRunner.query(
|
|
52
|
+
`DROP INDEX "public"."IDX_88d1e2bb9908f0aada30f044f5"`,
|
|
53
|
+
);
|
|
54
|
+
await queryRunner.query(
|
|
55
|
+
`DROP INDEX "public"."IDX_0ed4595b431ba465ac9a9938d4"`,
|
|
56
|
+
);
|
|
57
|
+
await queryRunner.query(
|
|
58
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
|
|
59
|
+
);
|
|
60
|
+
await queryRunner.query(
|
|
61
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
|
|
62
|
+
);
|
|
63
|
+
await queryRunner.query(
|
|
64
|
+
`CREATE INDEX "IDX_logscrub_isEnabled" ON "LogScrubRule" ("isEnabled") `,
|
|
65
|
+
);
|
|
66
|
+
await queryRunner.query(
|
|
67
|
+
`CREATE INDEX "IDX_logscrub_projectId" ON "LogScrubRule" ("projectId") `,
|
|
68
|
+
);
|
|
69
|
+
await queryRunner.query(
|
|
70
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_logscrub_deletedByUserId" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
71
|
+
);
|
|
72
|
+
await queryRunner.query(
|
|
73
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_logscrub_createdByUserId" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
74
|
+
);
|
|
75
|
+
await queryRunner.query(
|
|
76
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_logscrub_projectId" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1773500000000 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1773500000000";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "LogScrubRule" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "name" character varying(50) NOT NULL, "description" character varying(500), "patternType" character varying(100) NOT NULL, "customRegex" character varying(500), "scrubAction" character varying(100) NOT NULL DEFAULT 'redact', "fieldsToScrub" character varying(100) NOT NULL DEFAULT 'both', "isEnabled" boolean NOT NULL DEFAULT true, "sortOrder" integer NOT NULL DEFAULT '0', "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_logscrub_id" PRIMARY KEY ("_id"))`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`CREATE INDEX "IDX_logscrub_projectId" ON "LogScrubRule" ("projectId") `,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`CREATE INDEX "IDX_logscrub_isEnabled" ON "LogScrubRule" ("isEnabled") `,
|
|
15
|
+
);
|
|
16
|
+
await queryRunner.query(
|
|
17
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_logscrub_projectId" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
18
|
+
);
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_logscrub_createdByUserId" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
21
|
+
);
|
|
22
|
+
await queryRunner.query(
|
|
23
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_logscrub_deletedByUserId" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
28
|
+
await queryRunner.query(
|
|
29
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_logscrub_deletedByUserId"`,
|
|
30
|
+
);
|
|
31
|
+
await queryRunner.query(
|
|
32
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_logscrub_createdByUserId"`,
|
|
33
|
+
);
|
|
34
|
+
await queryRunner.query(
|
|
35
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_logscrub_projectId"`,
|
|
36
|
+
);
|
|
37
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_logscrub_isEnabled"`);
|
|
38
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_logscrub_projectId"`);
|
|
39
|
+
await queryRunner.query(`DROP TABLE "LogScrubRule"`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1773676206197 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1773676206197";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "LogScrubRule" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "name" character varying(50) NOT NULL, "description" character varying(500), "patternType" character varying(100) NOT NULL, "customRegex" character varying(500), "scrubAction" character varying(100) NOT NULL DEFAULT 'redact', "fieldsToScrub" character varying(100) NOT NULL DEFAULT 'both', "isEnabled" boolean NOT NULL DEFAULT true, "sortOrder" integer NOT NULL DEFAULT '0', "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_993a671224f0dca8edfd22bc788" PRIMARY KEY ("_id"))`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`CREATE INDEX "IDX_0ed4595b431ba465ac9a9938d4" ON "LogScrubRule" ("projectId") `,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`CREATE INDEX "IDX_88d1e2bb9908f0aada30f044f5" ON "LogScrubRule" ("isEnabled") `,
|
|
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
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_0ed4595b431ba465ac9a9938d4d" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
24
|
+
);
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_cec04acd064a11bf98c2eae3819" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
27
|
+
);
|
|
28
|
+
await queryRunner.query(
|
|
29
|
+
`ALTER TABLE "LogScrubRule" ADD CONSTRAINT "FK_88ad7031d2481dd8142e543ddbd" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
34
|
+
await queryRunner.query(
|
|
35
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_88ad7031d2481dd8142e543ddbd"`,
|
|
36
|
+
);
|
|
37
|
+
await queryRunner.query(
|
|
38
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_cec04acd064a11bf98c2eae3819"`,
|
|
39
|
+
);
|
|
40
|
+
await queryRunner.query(
|
|
41
|
+
`ALTER TABLE "LogScrubRule" DROP CONSTRAINT "FK_0ed4595b431ba465ac9a9938d4d"`,
|
|
42
|
+
);
|
|
43
|
+
await queryRunner.query(
|
|
44
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
|
|
45
|
+
);
|
|
46
|
+
await queryRunner.query(
|
|
47
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
|
|
48
|
+
);
|
|
49
|
+
await queryRunner.query(
|
|
50
|
+
`DROP INDEX "public"."IDX_88d1e2bb9908f0aada30f044f5"`,
|
|
51
|
+
);
|
|
52
|
+
await queryRunner.query(
|
|
53
|
+
`DROP INDEX "public"."IDX_0ed4595b431ba465ac9a9938d4"`,
|
|
54
|
+
);
|
|
55
|
+
await queryRunner.query(`DROP TABLE "LogScrubRule"`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -264,6 +264,8 @@ import { MigrationName1772280000000 } from "./1772280000000-MigrationName";
|
|
|
264
264
|
import { MigrationName1772350000000 } from "./1772350000000-MigrationName";
|
|
265
265
|
import { AddLogSavedView1772355000000 } from "./1772355000000-AddLogSavedView";
|
|
266
266
|
import { MigrationName1773344537755 } from "./1773344537755-MigrationName";
|
|
267
|
+
import { MigrationName1773402621107 } from "./1773402621107-MigrationName";
|
|
268
|
+
import { MigrationName1773676206197 } from "./1773676206197-MigrationName";
|
|
267
269
|
|
|
268
270
|
export default [
|
|
269
271
|
InitialMigration,
|
|
@@ -532,4 +534,6 @@ export default [
|
|
|
532
534
|
MigrationName1772350000000,
|
|
533
535
|
AddLogSavedView1772355000000,
|
|
534
536
|
MigrationName1773344537755,
|
|
537
|
+
MigrationName1773402621107,
|
|
538
|
+
MigrationName1773676206197,
|
|
535
539
|
];
|
|
@@ -238,6 +238,13 @@ export default class AnalyticsDatabaseService<
|
|
|
238
238
|
const statement: Statement =
|
|
239
239
|
this.statementGenerator.toAddColumnStatement(column);
|
|
240
240
|
await this.execute(statement);
|
|
241
|
+
|
|
242
|
+
// Add skip index separately (ClickHouse requires ADD INDEX as a separate ALTER statement)
|
|
243
|
+
const indexStatement: Statement | null =
|
|
244
|
+
this.statementGenerator.toAddSkipIndexStatement(column);
|
|
245
|
+
if (indexStatement) {
|
|
246
|
+
await this.execute(indexStatement);
|
|
247
|
+
}
|
|
241
248
|
}
|
|
242
249
|
|
|
243
250
|
@CaptureSpan()
|
|
@@ -247,6 +254,60 @@ export default class AnalyticsDatabaseService<
|
|
|
247
254
|
);
|
|
248
255
|
}
|
|
249
256
|
|
|
257
|
+
public async doesColumnExist(columnName: string): Promise<boolean> {
|
|
258
|
+
const tableName: string = this.model.tableName;
|
|
259
|
+
const result: { data: Array<JSONObject> } = await (
|
|
260
|
+
await this.executeQuery(
|
|
261
|
+
`SELECT count() as cnt FROM system.columns WHERE database = currentDatabase() AND table = '${tableName}' AND name = '${columnName}'`,
|
|
262
|
+
)
|
|
263
|
+
).json();
|
|
264
|
+
|
|
265
|
+
const rows: Array<JSONObject> = result.data || [];
|
|
266
|
+
|
|
267
|
+
return rows.length > 0 && Number(rows[0]!["cnt"]) > 0;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
public async getColumnCodec(columnName: string): Promise<string> {
|
|
271
|
+
const tableName: string = this.model.tableName;
|
|
272
|
+
const result: { data: Array<JSONObject> } = await (
|
|
273
|
+
await this.executeQuery(
|
|
274
|
+
`SELECT compression_codec FROM system.columns WHERE database = currentDatabase() AND table = '${tableName}' AND name = '${columnName}'`,
|
|
275
|
+
)
|
|
276
|
+
).json();
|
|
277
|
+
|
|
278
|
+
const rows: Array<JSONObject> = result.data || [];
|
|
279
|
+
|
|
280
|
+
if (rows.length === 0) {
|
|
281
|
+
return "";
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return (rows[0]!["compression_codec"] as string) || "";
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
public async setColumnCodecIfNotSet(data: {
|
|
288
|
+
columnName: string;
|
|
289
|
+
columnType: string;
|
|
290
|
+
codec: string;
|
|
291
|
+
expectedCodecValue: string;
|
|
292
|
+
}): Promise<void> {
|
|
293
|
+
const tableName: string = this.model.tableName;
|
|
294
|
+
const currentCodec: string = await this.getColumnCodec(data.columnName);
|
|
295
|
+
|
|
296
|
+
if (currentCodec === data.expectedCodecValue) {
|
|
297
|
+
logger.info(
|
|
298
|
+
`${tableName}.${data.columnName} already has ${data.expectedCodecValue}, skipping`,
|
|
299
|
+
);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
await this.execute(
|
|
304
|
+
`ALTER TABLE ${tableName} MODIFY COLUMN ${data.columnName} ${data.columnType} CODEC(${data.codec}) SETTINGS mutations_sync=0`,
|
|
305
|
+
);
|
|
306
|
+
logger.info(
|
|
307
|
+
`Applied ${data.codec} codec to ${tableName}.${data.columnName} (async)`,
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
250
311
|
@CaptureSpan()
|
|
251
312
|
public async findBy(findBy: FindBy<TBaseModel>): Promise<Array<TBaseModel>> {
|
|
252
313
|
return await this._findBy(findBy);
|