efiber-prisma-schema 1.12.14 → 1.12.16

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.12.14",
3
+ "version": "1.12.16",
4
4
  "description": "Database schema for eFiber",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,5 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Revision" ADD COLUMN "clusterId" TEXT;
3
+
4
+ -- AddForeignKey
5
+ ALTER TABLE "Revision" ADD CONSTRAINT "Revision_clusterId_fkey" FOREIGN KEY ("clusterId") REFERENCES "Cluster"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,191 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "RelationType" AS ENUM ('INSTALLED_ON', 'CONNECTED_TO', 'ENCLOSURE_ORIGIN', 'ENCLOSURE_DESTINATION');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "AttributeType" AS ENUM ('TEXT', 'NUMBER', 'BOOLEAN', 'DROPDOWN', 'OPTIONS', 'DATE', 'JSON');
6
+
7
+ -- AlterTable
8
+ ALTER TABLE "Building" ADD COLUMN "nodeId" TEXT;
9
+
10
+ -- AlterTable
11
+ ALTER TABLE "Cable" ADD COLUMN "nodeId" TEXT;
12
+
13
+ -- AlterTable
14
+ ALTER TABLE "FDTSRO" ADD COLUMN "nodeId" TEXT;
15
+
16
+ -- AlterTable
17
+ ALTER TABLE "Loop" ADD COLUMN "nodeId" TEXT;
18
+
19
+ -- AlterTable
20
+ ALTER TABLE "Manhole" ADD COLUMN "nodeId" TEXT;
21
+
22
+ -- AlterTable
23
+ ALTER TABLE "MapElement" ADD COLUMN "nodeId" TEXT;
24
+
25
+ -- AlterTable
26
+ ALTER TABLE "PboFat" ADD COLUMN "nodeId" TEXT;
27
+
28
+ -- AlterTable
29
+ ALTER TABLE "Pole" ADD COLUMN "nodeId" TEXT;
30
+
31
+ -- AlterTable
32
+ ALTER TABLE "SFU" ADD COLUMN "nodeId" TEXT;
33
+
34
+ -- AlterTable
35
+ ALTER TABLE "SpliceClosure" ADD COLUMN "nodeId" TEXT;
36
+
37
+ -- AlterTable
38
+ ALTER TABLE "ZoneNro" ADD COLUMN "nodeId" TEXT;
39
+
40
+ -- CreateTable
41
+ CREATE TABLE "ElementNode" (
42
+ "id" TEXT NOT NULL,
43
+ "typeId" TEXT NOT NULL,
44
+ "name" TEXT NOT NULL,
45
+ "lat" DOUBLE PRECISION,
46
+ "lng" DOUBLE PRECISION,
47
+ "geometry" JSONB,
48
+ "isInstalled" BOOLEAN NOT NULL DEFAULT false,
49
+ "installationDate" TIMESTAMP(3),
50
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
51
+ "updatedAt" TIMESTAMP(3) NOT NULL,
52
+
53
+ CONSTRAINT "ElementNode_pkey" PRIMARY KEY ("id")
54
+ );
55
+
56
+ -- CreateTable
57
+ CREATE TABLE "ElementRelation" (
58
+ "id" TEXT NOT NULL,
59
+ "fromId" TEXT NOT NULL,
60
+ "toId" TEXT NOT NULL,
61
+ "relationType" "RelationType" NOT NULL,
62
+ "metadata" JSONB,
63
+ "clusterId" TEXT,
64
+
65
+ CONSTRAINT "ElementRelation_pkey" PRIMARY KEY ("id")
66
+ );
67
+
68
+ -- CreateTable
69
+ CREATE TABLE "AttributeDefinition" (
70
+ "id" TEXT NOT NULL,
71
+ "no" SERIAL NOT NULL,
72
+ "key" TEXT NOT NULL,
73
+ "label" TEXT NOT NULL,
74
+ "type" "AttributeType" NOT NULL,
75
+ "required" BOOLEAN NOT NULL DEFAULT false,
76
+ "visibleOnWeb" BOOLEAN NOT NULL DEFAULT true,
77
+ "visibleOnMobile" BOOLEAN NOT NULL DEFAULT true,
78
+
79
+ CONSTRAINT "AttributeDefinition_pkey" PRIMARY KEY ("id")
80
+ );
81
+
82
+ -- CreateTable
83
+ CREATE TABLE "OptionSource" (
84
+ "id" TEXT NOT NULL,
85
+ "sourceType" TEXT NOT NULL,
86
+ "staticOptions" JSONB,
87
+ "dynamicOptions" JSONB,
88
+ "foreignTable" TEXT,
89
+
90
+ CONSTRAINT "OptionSource_pkey" PRIMARY KEY ("id")
91
+ );
92
+
93
+ -- CreateTable
94
+ CREATE TABLE "AttributeValue" (
95
+ "id" TEXT NOT NULL,
96
+ "attributeDefId" TEXT NOT NULL,
97
+ "value" TEXT NOT NULL,
98
+ "nodeId" TEXT NOT NULL,
99
+
100
+ CONSTRAINT "AttributeValue_pkey" PRIMARY KEY ("id")
101
+ );
102
+
103
+ -- CreateIndex
104
+ CREATE UNIQUE INDEX "ElementNode_id_key" ON "ElementNode"("id");
105
+
106
+ -- CreateIndex
107
+ CREATE UNIQUE INDEX "ElementRelation_id_key" ON "ElementRelation"("id");
108
+
109
+ -- CreateIndex
110
+ CREATE INDEX "ElementRelation_fromId_idx" ON "ElementRelation"("fromId");
111
+
112
+ -- CreateIndex
113
+ CREATE INDEX "ElementRelation_toId_idx" ON "ElementRelation"("toId");
114
+
115
+ -- CreateIndex
116
+ CREATE INDEX "ElementRelation_relationType_idx" ON "ElementRelation"("relationType");
117
+
118
+ -- CreateIndex
119
+ CREATE UNIQUE INDEX "AttributeDefinition_id_key" ON "AttributeDefinition"("id");
120
+
121
+ -- CreateIndex
122
+ CREATE UNIQUE INDEX "AttributeDefinition_key_key" ON "AttributeDefinition"("key");
123
+
124
+ -- CreateIndex
125
+ CREATE UNIQUE INDEX "OptionSource_id_key" ON "OptionSource"("id");
126
+
127
+ -- CreateIndex
128
+ CREATE UNIQUE INDEX "AttributeValue_id_key" ON "AttributeValue"("id");
129
+
130
+ -- CreateIndex
131
+ CREATE INDEX "AttributeValue_nodeId_idx" ON "AttributeValue"("nodeId");
132
+
133
+ -- CreateIndex
134
+ CREATE INDEX "AttributeValue_attributeDefId_idx" ON "AttributeValue"("attributeDefId");
135
+
136
+ -- CreateIndex
137
+ CREATE INDEX "PboFat_nodeId_idx" ON "PboFat"("nodeId");
138
+
139
+ -- CreateIndex
140
+ CREATE INDEX "PboFat_clusterId_idx" ON "PboFat"("clusterId");
141
+
142
+ -- AddForeignKey
143
+ ALTER TABLE "ElementNode" ADD CONSTRAINT "ElementNode_typeId_fkey" FOREIGN KEY ("typeId") REFERENCES "NetworkElement"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
144
+
145
+ -- AddForeignKey
146
+ ALTER TABLE "ElementRelation" ADD CONSTRAINT "ElementRelation_fromId_fkey" FOREIGN KEY ("fromId") REFERENCES "ElementNode"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
147
+
148
+ -- AddForeignKey
149
+ ALTER TABLE "ElementRelation" ADD CONSTRAINT "ElementRelation_toId_fkey" FOREIGN KEY ("toId") REFERENCES "ElementNode"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
150
+
151
+ -- AddForeignKey
152
+ ALTER TABLE "ElementRelation" ADD CONSTRAINT "ElementRelation_clusterId_fkey" FOREIGN KEY ("clusterId") REFERENCES "Cluster"("id") ON DELETE SET NULL ON UPDATE CASCADE;
153
+
154
+ -- AddForeignKey
155
+ ALTER TABLE "AttributeValue" ADD CONSTRAINT "AttributeValue_attributeDefId_fkey" FOREIGN KEY ("attributeDefId") REFERENCES "AttributeDefinition"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
156
+
157
+ -- AddForeignKey
158
+ ALTER TABLE "AttributeValue" ADD CONSTRAINT "AttributeValue_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
159
+
160
+ -- AddForeignKey
161
+ ALTER TABLE "Cable" ADD CONSTRAINT "Cable_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
162
+
163
+ -- AddForeignKey
164
+ ALTER TABLE "PboFat" ADD CONSTRAINT "PboFat_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
165
+
166
+ -- AddForeignKey
167
+ ALTER TABLE "SpliceClosure" ADD CONSTRAINT "SpliceClosure_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
168
+
169
+ -- AddForeignKey
170
+ ALTER TABLE "ZoneNro" ADD CONSTRAINT "ZoneNro_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
171
+
172
+ -- AddForeignKey
173
+ ALTER TABLE "Pole" ADD CONSTRAINT "Pole_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
174
+
175
+ -- AddForeignKey
176
+ ALTER TABLE "Manhole" ADD CONSTRAINT "Manhole_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
177
+
178
+ -- AddForeignKey
179
+ ALTER TABLE "Loop" ADD CONSTRAINT "Loop_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
180
+
181
+ -- AddForeignKey
182
+ ALTER TABLE "FDTSRO" ADD CONSTRAINT "FDTSRO_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
183
+
184
+ -- AddForeignKey
185
+ ALTER TABLE "SFU" ADD CONSTRAINT "SFU_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
186
+
187
+ -- AddForeignKey
188
+ ALTER TABLE "Building" ADD CONSTRAINT "Building_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
189
+
190
+ -- AddForeignKey
191
+ ALTER TABLE "MapElement" ADD CONSTRAINT "MapElement_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "ElementNode"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -110,6 +110,23 @@ enum RevisionStatus {
110
110
  REJECTED
111
111
  }
112
112
 
113
+ enum RelationType {
114
+ INSTALLED_ON
115
+ CONNECTED_TO
116
+ ENCLOSURE_ORIGIN
117
+ ENCLOSURE_DESTINATION
118
+ }
119
+
120
+ enum AttributeType {
121
+ TEXT
122
+ NUMBER
123
+ BOOLEAN
124
+ DROPDOWN
125
+ OPTIONS
126
+ DATE
127
+ JSON
128
+ }
129
+
113
130
  model Country {
114
131
  id String @id @unique @default(uuid())
115
132
  no Int @default(autoincrement())
@@ -1354,6 +1371,89 @@ model NetworkElement {
1354
1371
  BuildingTemplate BuildingTemplate[]
1355
1372
  MapElementTemplate MapElementTemplate[]
1356
1373
  MapElement MapElement[]
1374
+ ElementNode ElementNode[]
1375
+ }
1376
+
1377
+ model ElementNode {
1378
+ id String @id @unique @default(uuid())
1379
+ typeId String
1380
+ type NetworkElement @relation(fields: [typeId], references: [id])
1381
+ name String
1382
+ lat Float?
1383
+ lng Float?
1384
+ geometry Json?
1385
+
1386
+ isInstalled Boolean @default(false)
1387
+ installationDate DateTime?
1388
+
1389
+ relationsFrom ElementRelation[] @relation("relationsFrom")
1390
+ relationsTo ElementRelation[] @relation("relationsTo")
1391
+
1392
+ createdAt DateTime @default(now())
1393
+ updatedAt DateTime @updatedAt
1394
+ AttributeValues AttributeValue[]
1395
+ PboFat PboFat[]
1396
+ Cable Cable[]
1397
+ SpliceClosure SpliceClosure[]
1398
+ ZoneNro ZoneNro[]
1399
+ Pole Pole[]
1400
+ Manhole Manhole[]
1401
+ Loop Loop[]
1402
+ FDTSRO FDTSRO[]
1403
+ SFU SFU[]
1404
+ Building Building[]
1405
+ MapElement MapElement[]
1406
+ }
1407
+
1408
+ model ElementRelation {
1409
+ id String @id @unique @default(uuid())
1410
+ fromId String
1411
+ toId String
1412
+ relationType RelationType
1413
+ metadata Json?
1414
+ from ElementNode @relation("relationsFrom", fields: [fromId], references: [id])
1415
+ to ElementNode @relation("relationsTo", fields: [toId], references: [id])
1416
+
1417
+ clusterId String?
1418
+ cluster Cluster? @relation(fields: [clusterId], references: [id])
1419
+
1420
+ @@index([fromId])
1421
+ @@index([toId])
1422
+ @@index([relationType])
1423
+ }
1424
+
1425
+ model AttributeDefinition {
1426
+ id String @id @unique @default(uuid())
1427
+ no Int @default(autoincrement())
1428
+ key String @unique
1429
+ label String
1430
+ type AttributeType
1431
+
1432
+ required Boolean @default(false)
1433
+ visibleOnWeb Boolean @default(true)
1434
+ visibleOnMobile Boolean @default(true)
1435
+ AttributeValue AttributeValue[]
1436
+ }
1437
+
1438
+ model OptionSource {
1439
+ id String @id @unique @default(uuid())
1440
+ sourceType String
1441
+ staticOptions Json?
1442
+ dynamicOptions Json?
1443
+ foreignTable String?
1444
+ }
1445
+
1446
+ model AttributeValue {
1447
+ id String @id @unique @default(uuid())
1448
+ attributeDefId String
1449
+ attributeDef AttributeDefinition @relation(fields: [attributeDefId], references: [id])
1450
+ value String //Always store as string, convert to other types in the application layer
1451
+
1452
+ node ElementNode @relation(fields: [nodeId], references: [id])
1453
+ nodeId String
1454
+
1455
+ @@index([nodeId])
1456
+ @@index([attributeDefId])
1357
1457
  }
1358
1458
 
1359
1459
  model Cable {
@@ -1403,6 +1503,9 @@ model Cable {
1403
1503
  project Project? @relation(fields: [projectId], references: [id])
1404
1504
  projectId String?
1405
1505
 
1506
+ node ElementNode? @relation(fields: [nodeId], references: [id])
1507
+ nodeId String?
1508
+
1406
1509
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
1407
1510
  installationId String?
1408
1511
 
@@ -1582,8 +1685,14 @@ model PboFat {
1582
1685
  cluster Cluster? @relation(fields: [clusterId], references: [id])
1583
1686
  clusterId String?
1584
1687
 
1688
+ node ElementNode? @relation(fields: [nodeId], references: [id])
1689
+ nodeId String?
1690
+
1585
1691
  dependencies PreviousEquipment[]
1586
1692
  Revision Revision[]
1693
+
1694
+ @@index([nodeId])
1695
+ @@index([clusterId])
1587
1696
  }
1588
1697
 
1589
1698
  model PboFatAttributes {
@@ -1663,6 +1772,9 @@ model SpliceClosure {
1663
1772
  cluster Cluster? @relation(fields: [clusterId], references: [id])
1664
1773
  clusterId String?
1665
1774
 
1775
+ node ElementNode? @relation(fields: [nodeId], references: [id])
1776
+ nodeId String?
1777
+
1666
1778
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
1667
1779
  installationId String?
1668
1780
 
@@ -1775,6 +1887,9 @@ model ZoneNro {
1775
1887
  cluster Cluster? @relation(fields: [clusterId], references: [id])
1776
1888
  clusterId String?
1777
1889
 
1890
+ node ElementNode? @relation(fields: [nodeId], references: [id])
1891
+ nodeId String?
1892
+
1778
1893
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
1779
1894
  installationId String?
1780
1895
 
@@ -1862,6 +1977,9 @@ model Pole {
1862
1977
  cluster Cluster? @relation(fields: [clusterId], references: [id])
1863
1978
  clusterId String?
1864
1979
 
1980
+ node ElementNode? @relation(fields: [nodeId], references: [id])
1981
+ nodeId String?
1982
+
1865
1983
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
1866
1984
  installationId String?
1867
1985
 
@@ -1949,6 +2067,9 @@ model Manhole {
1949
2067
  cluster Cluster? @relation(fields: [clusterId], references: [id])
1950
2068
  clusterId String?
1951
2069
 
2070
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2071
+ nodeId String?
2072
+
1952
2073
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
1953
2074
  installationId String?
1954
2075
 
@@ -2036,6 +2157,9 @@ model Loop {
2036
2157
  cluster Cluster? @relation(fields: [clusterId], references: [id])
2037
2158
  clusterId String?
2038
2159
 
2160
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2161
+ nodeId String?
2162
+
2039
2163
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
2040
2164
  installationId String?
2041
2165
 
@@ -2126,6 +2250,9 @@ model FDTSRO {
2126
2250
  cluster Cluster? @relation(fields: [clusterId], references: [id])
2127
2251
  clusterId String?
2128
2252
 
2253
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2254
+ nodeId String?
2255
+
2129
2256
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
2130
2257
  installationId String?
2131
2258
 
@@ -2214,6 +2341,9 @@ model SFU {
2214
2341
  cluster Cluster? @relation(fields: [clusterId], references: [id])
2215
2342
  clusterId String?
2216
2343
 
2344
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2345
+ nodeId String?
2346
+
2217
2347
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
2218
2348
  installationId String?
2219
2349
 
@@ -2307,6 +2437,9 @@ model Building {
2307
2437
  cluster Cluster? @relation(fields: [clusterId], references: [id])
2308
2438
  clusterId String?
2309
2439
 
2440
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2441
+ nodeId String?
2442
+
2310
2443
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
2311
2444
  installationId String?
2312
2445
 
@@ -2370,6 +2503,8 @@ model Revision {
2370
2503
  createdById String?
2371
2504
  resolvedById String?
2372
2505
 
2506
+ clusterId String?
2507
+
2373
2508
  createdAt DateTime @default(now())
2374
2509
  updatedAt DateTime @updatedAt
2375
2510
  resolvedAt DateTime?
@@ -2388,6 +2523,8 @@ model Revision {
2388
2523
 
2389
2524
  createdBy User? @relation("revisionCreatedBy", fields: [createdById], references: [id])
2390
2525
  resolvedBy User? @relation("revisionResolvedBy", fields: [resolvedById], references: [id])
2526
+
2527
+ cluster Cluster? @relation(fields: [clusterId], references: [id])
2391
2528
  }
2392
2529
 
2393
2530
  model MapElementTemplate {
@@ -2459,6 +2596,9 @@ model MapElement {
2459
2596
  cluster Cluster? @relation(fields: [clusterId], references: [id])
2460
2597
  clusterId String?
2461
2598
 
2599
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2600
+ nodeId String?
2601
+
2462
2602
  qrCodeTag qrCodeTag[]
2463
2603
  }
2464
2604
 
@@ -2555,6 +2695,8 @@ model Cluster {
2555
2695
  MapElementTemplate MapElementTemplate[]
2556
2696
  MapElement MapElement[]
2557
2697
  ClusterComments ClusterComments[]
2698
+ Revision Revision[]
2699
+ ElementRelation ElementRelation[]
2558
2700
  }
2559
2701
 
2560
2702
  model ClusterComments {