efiber-prisma-schema 1.11.3 → 1.11.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efiber-prisma-schema",
3
- "version": "1.11.3",
3
+ "version": "1.11.5",
4
4
  "description": "Database schema for eFiber",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,136 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "ProjectLevel" AS ENUM ('Subsidiary', 'Client', 'MainProject', 'Project', 'CentralOffice', 'Cluster');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "AggregationOperation" AS ENUM ('LIST', 'SUM', 'COUNT', 'AVERAGE');
6
+
7
+ -- CreateEnum
8
+ CREATE TYPE "ArithmeticOperation" AS ENUM ('ADD', 'SUBTRACT', 'MULTIPLY', 'DIVIDE');
9
+
10
+ -- CreateEnum
11
+ CREATE TYPE "ReportUsage" AS ENUM ('TABLE', 'VISUALIZATION');
12
+
13
+ -- CreateEnum
14
+ CREATE TYPE "ValueFormat" AS ENUM ('PERCENTAGE', 'NUMBER');
15
+
16
+ -- CreateEnum
17
+ CREATE TYPE "ChartType" AS ENUM ('BAR', 'LINE', 'PIE');
18
+
19
+ -- AlterTable
20
+ ALTER TABLE "Building" ADD COLUMN "flatsPerFloor" INTEGER,
21
+ ADD COLUMN "floorCount" INTEGER,
22
+ ADD COLUMN "totalFlats" INTEGER;
23
+
24
+ -- AlterTable
25
+ ALTER TABLE "Cable" ADD COLUMN "cableLength" DOUBLE PRECISION;
26
+
27
+ -- AlterTable
28
+ ALTER TABLE "FDTSRO" ADD COLUMN "fdtsroMaxCapacity" INTEGER;
29
+
30
+ -- AlterTable
31
+ ALTER TABLE "PboFat" ADD COLUMN "fatAvailableCapacity" INTEGER,
32
+ ADD COLUMN "fatExistingSubscribers" INTEGER,
33
+ ADD COLUMN "fatMaxCapacity" INTEGER;
34
+
35
+ -- AlterTable
36
+ ALTER TABLE "SpliceClosure" ADD COLUMN "spliceClosureMaxCapacity" INTEGER;
37
+
38
+ -- AlterTable
39
+ ALTER TABLE "ZoneNro" ADD COLUMN "zoneHouseCount" INTEGER;
40
+
41
+ -- CreateTable
42
+ CREATE TABLE "IntegrationReportTemplate" (
43
+ "id" TEXT NOT NULL,
44
+ "no" SERIAL NOT NULL,
45
+ "name" TEXT NOT NULL,
46
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
47
+ "updatedAt" TIMESTAMP(3) NOT NULL,
48
+ "deletedAt" TIMESTAMP(3),
49
+ "createdById" TEXT,
50
+
51
+ CONSTRAINT "IntegrationReportTemplate_pkey" PRIMARY KEY ("id")
52
+ );
53
+
54
+ -- CreateTable
55
+ CREATE TABLE "ReportMetric" (
56
+ "id" TEXT NOT NULL,
57
+ "reportTemplateId" TEXT NOT NULL,
58
+ "elementType" "NetworkElementChildType" NOT NULL,
59
+ "attributeName" TEXT NOT NULL,
60
+ "formula" "AggregationOperation" NOT NULL,
61
+ "groupByLevel" "ProjectLevel" NOT NULL,
62
+ "usage" "ReportUsage"[] DEFAULT ARRAY['TABLE']::"ReportUsage"[],
63
+
64
+ CONSTRAINT "ReportMetric_pkey" PRIMARY KEY ("id")
65
+ );
66
+
67
+ -- CreateTable
68
+ CREATE TABLE "ReportFormulaConfig" (
69
+ "metricId" TEXT NOT NULL,
70
+ "resultName" TEXT NOT NULL,
71
+ "numberOfVariables" INTEGER NOT NULL,
72
+ "variableAttributes" JSONB NOT NULL,
73
+ "operations" "ArithmeticOperation"[],
74
+ "resultFormat" "ValueFormat" NOT NULL DEFAULT 'NUMBER',
75
+
76
+ CONSTRAINT "ReportFormulaConfig_pkey" PRIMARY KEY ("metricId")
77
+ );
78
+
79
+ -- CreateTable
80
+ CREATE TABLE "ReportVisualization" (
81
+ "id" TEXT NOT NULL,
82
+ "templateId" TEXT NOT NULL,
83
+ "metricId" TEXT NOT NULL,
84
+ "chartType" "ChartType" NOT NULL,
85
+ "xAxisField" TEXT,
86
+ "yAxisField" TEXT,
87
+ "useCustomColors" BOOLEAN NOT NULL DEFAULT false,
88
+ "customColors" JSONB,
89
+
90
+ CONSTRAINT "ReportVisualization_pkey" PRIMARY KEY ("id")
91
+ );
92
+
93
+ -- CreateTable
94
+ CREATE TABLE "ReportTable" (
95
+ "id" TEXT NOT NULL,
96
+ "templateId" TEXT NOT NULL,
97
+ "metricId" TEXT NOT NULL,
98
+ "columns" TEXT[],
99
+ "includeHeader" BOOLEAN NOT NULL DEFAULT true,
100
+ "sortBy" JSONB,
101
+
102
+ CONSTRAINT "ReportTable_pkey" PRIMARY KEY ("id")
103
+ );
104
+
105
+ -- CreateIndex
106
+ CREATE UNIQUE INDEX "IntegrationReportTemplate_id_key" ON "IntegrationReportTemplate"("id");
107
+
108
+ -- CreateIndex
109
+ CREATE UNIQUE INDEX "ReportMetric_id_key" ON "ReportMetric"("id");
110
+
111
+ -- CreateIndex
112
+ CREATE UNIQUE INDEX "ReportVisualization_id_key" ON "ReportVisualization"("id");
113
+
114
+ -- CreateIndex
115
+ CREATE UNIQUE INDEX "ReportTable_id_key" ON "ReportTable"("id");
116
+
117
+ -- AddForeignKey
118
+ ALTER TABLE "IntegrationReportTemplate" ADD CONSTRAINT "IntegrationReportTemplate_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
119
+
120
+ -- AddForeignKey
121
+ ALTER TABLE "ReportMetric" ADD CONSTRAINT "ReportMetric_reportTemplateId_fkey" FOREIGN KEY ("reportTemplateId") REFERENCES "IntegrationReportTemplate"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
122
+
123
+ -- AddForeignKey
124
+ ALTER TABLE "ReportFormulaConfig" ADD CONSTRAINT "ReportFormulaConfig_metricId_fkey" FOREIGN KEY ("metricId") REFERENCES "ReportMetric"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
125
+
126
+ -- AddForeignKey
127
+ ALTER TABLE "ReportVisualization" ADD CONSTRAINT "ReportVisualization_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "IntegrationReportTemplate"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
128
+
129
+ -- AddForeignKey
130
+ ALTER TABLE "ReportVisualization" ADD CONSTRAINT "ReportVisualization_metricId_fkey" FOREIGN KEY ("metricId") REFERENCES "ReportMetric"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
131
+
132
+ -- AddForeignKey
133
+ ALTER TABLE "ReportTable" ADD CONSTRAINT "ReportTable_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "IntegrationReportTemplate"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
134
+
135
+ -- AddForeignKey
136
+ ALTER TABLE "ReportTable" ADD CONSTRAINT "ReportTable_metricId_fkey" FOREIGN KEY ("metricId") REFERENCES "ReportMetric"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -0,0 +1,4 @@
1
+ -- AlterTable
2
+ ALTER TABLE "ReportMetric" ALTER COLUMN "elementType" DROP NOT NULL,
3
+ ALTER COLUMN "formula" DROP NOT NULL,
4
+ ALTER COLUMN "groupByLevel" DROP NOT NULL;
@@ -0,0 +1,12 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `metricId` on the `ReportVisualization` table. All the data in the column will be lost.
5
+
6
+ */
7
+ -- DropForeignKey
8
+ ALTER TABLE "ReportVisualization" DROP CONSTRAINT "ReportVisualization_metricId_fkey";
9
+
10
+ -- AlterTable
11
+ ALTER TABLE "ReportVisualization" DROP COLUMN "metricId",
12
+ ADD COLUMN "metricIds" TEXT[];
@@ -2432,32 +2432,31 @@ model ReportMetric {
2432
2432
  reportTemplate IntegrationReportTemplate @relation(fields: [reportTemplateId], references: [id])
2433
2433
  reportTemplateId String
2434
2434
 
2435
- elementType NetworkElementChildType
2436
- attributeName String //Name of the attribute to be reported
2435
+ elementType NetworkElementChildType?
2436
+ attributeName String //Name of the attribute to be reported
2437
2437
 
2438
2438
  // Aggregation across records
2439
- formula AggregationOperation
2440
- groupByLevel ProjectLevel
2441
-
2439
+ formula AggregationOperation?
2440
+ groupByLevel ProjectLevel?
2441
+
2442
2442
  // Formula configuration
2443
2443
  formulaConfig ReportFormulaConfig?
2444
2444
 
2445
2445
  // Usage Classification
2446
- usage ReportUsage[] @default([TABLE])
2446
+ usage ReportUsage[] @default([TABLE])
2447
2447
 
2448
- visualizations ReportVisualization[]
2449
2448
  ReportTable ReportTable[]
2450
2449
  }
2451
2450
 
2452
2451
  model ReportFormulaConfig {
2453
- metricId String @id
2454
- metric ReportMetric @relation(fields: [metricId], references: [id])
2452
+ metricId String @id
2453
+ metric ReportMetric @relation(fields: [metricId], references: [id])
2455
2454
 
2456
- resultName String //Name of the result to be reported
2457
- numberOfVariables Int //Number of variables in the formula
2455
+ resultName String //Name of the result to be reported
2456
+ numberOfVariables Int //Number of variables in the formula
2458
2457
  variableAttributes Json //e.g {"variable1": "Client Name", "variable2": "Fat Available Capacity"}
2459
2458
  operations ArithmeticOperation[] //e.g {"operation1": "sum", "operation2": "average"}
2460
- resultFormat ValueFormat @default(NUMBER)
2459
+ resultFormat ValueFormat @default(NUMBER)
2461
2460
  }
2462
2461
 
2463
2462
  model ReportVisualization {
@@ -2466,8 +2465,7 @@ model ReportVisualization {
2466
2465
  template IntegrationReportTemplate @relation(fields: [templateId], references: [id])
2467
2466
  templateId String
2468
2467
 
2469
- metric ReportMetric @relation(fields: [metricId], references: [id])
2470
- metricId String
2468
+ metricIds String[] //List of ReportMetric IDs to be visualized
2471
2469
 
2472
2470
  chartType ChartType
2473
2471
  xAxisField String? //e.g "Client Name"