efiber-prisma-schema 1.12.15 → 1.12.17

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.15",
3
+ "version": "1.12.17",
4
4
  "description": "Database schema for eFiber",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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;
@@ -0,0 +1,27 @@
1
+ -- AlterTable
2
+ ALTER TABLE "AttributeDefinition" ADD COLUMN "visibleOnDispatchMobile" BOOLEAN NOT NULL DEFAULT true;
3
+
4
+ -- CreateTable
5
+ CREATE TABLE "ClusterNotes" (
6
+ "id" TEXT NOT NULL,
7
+ "no" SERIAL NOT NULL,
8
+ "comment" TEXT NOT NULL,
9
+ "hasPicture" BOOLEAN NOT NULL DEFAULT false,
10
+ "coordinates" JSONB,
11
+ "picture" TEXT,
12
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
13
+ "updatedAt" TIMESTAMP(3) NOT NULL,
14
+ "createdById" TEXT NOT NULL,
15
+ "clusterId" TEXT NOT NULL,
16
+
17
+ CONSTRAINT "ClusterNotes_pkey" PRIMARY KEY ("id")
18
+ );
19
+
20
+ -- CreateIndex
21
+ CREATE UNIQUE INDEX "ClusterNotes_id_key" ON "ClusterNotes"("id");
22
+
23
+ -- AddForeignKey
24
+ ALTER TABLE "ClusterNotes" ADD CONSTRAINT "ClusterNotes_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
25
+
26
+ -- AddForeignKey
27
+ ALTER TABLE "ClusterNotes" ADD CONSTRAINT "ClusterNotes_clusterId_fkey" FOREIGN KEY ("clusterId") REFERENCES "Cluster"("id") ON DELETE RESTRICT 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())
@@ -501,6 +518,7 @@ model User {
501
518
  ClusterComments ClusterComments[]
502
519
  CreatedRevisions Revision[] @relation("revisionCreatedBy")
503
520
  ResolvedRevisions Revision[] @relation("revisionResolvedBy")
521
+ ClusterNotes ClusterNotes[]
504
522
  }
505
523
 
506
524
  model MainProject {
@@ -1354,6 +1372,90 @@ model NetworkElement {
1354
1372
  BuildingTemplate BuildingTemplate[]
1355
1373
  MapElementTemplate MapElementTemplate[]
1356
1374
  MapElement MapElement[]
1375
+ ElementNode ElementNode[]
1376
+ }
1377
+
1378
+ model ElementNode {
1379
+ id String @id @unique @default(uuid())
1380
+ typeId String
1381
+ type NetworkElement @relation(fields: [typeId], references: [id])
1382
+ name String
1383
+ lat Float?
1384
+ lng Float?
1385
+ geometry Json?
1386
+
1387
+ isInstalled Boolean @default(false)
1388
+ installationDate DateTime?
1389
+
1390
+ relationsFrom ElementRelation[] @relation("relationsFrom")
1391
+ relationsTo ElementRelation[] @relation("relationsTo")
1392
+
1393
+ createdAt DateTime @default(now())
1394
+ updatedAt DateTime @updatedAt
1395
+ AttributeValues AttributeValue[]
1396
+ PboFat PboFat[]
1397
+ Cable Cable[]
1398
+ SpliceClosure SpliceClosure[]
1399
+ ZoneNro ZoneNro[]
1400
+ Pole Pole[]
1401
+ Manhole Manhole[]
1402
+ Loop Loop[]
1403
+ FDTSRO FDTSRO[]
1404
+ SFU SFU[]
1405
+ Building Building[]
1406
+ MapElement MapElement[]
1407
+ }
1408
+
1409
+ model ElementRelation {
1410
+ id String @id @unique @default(uuid())
1411
+ fromId String
1412
+ toId String
1413
+ relationType RelationType
1414
+ metadata Json?
1415
+ from ElementNode @relation("relationsFrom", fields: [fromId], references: [id])
1416
+ to ElementNode @relation("relationsTo", fields: [toId], references: [id])
1417
+
1418
+ clusterId String?
1419
+ cluster Cluster? @relation(fields: [clusterId], references: [id])
1420
+
1421
+ @@index([fromId])
1422
+ @@index([toId])
1423
+ @@index([relationType])
1424
+ }
1425
+
1426
+ model AttributeDefinition {
1427
+ id String @id @unique @default(uuid())
1428
+ no Int @default(autoincrement())
1429
+ key String @unique
1430
+ label String
1431
+ type AttributeType
1432
+
1433
+ required Boolean @default(false)
1434
+ visibleOnWeb Boolean @default(true)
1435
+ visibleOnMobile Boolean @default(true)
1436
+ visibleOnDispatchMobile Boolean @default(true)
1437
+ AttributeValue AttributeValue[]
1438
+ }
1439
+
1440
+ model OptionSource {
1441
+ id String @id @unique @default(uuid())
1442
+ sourceType String
1443
+ staticOptions Json?
1444
+ dynamicOptions Json?
1445
+ foreignTable String?
1446
+ }
1447
+
1448
+ model AttributeValue {
1449
+ id String @id @unique @default(uuid())
1450
+ attributeDefId String
1451
+ attributeDef AttributeDefinition @relation(fields: [attributeDefId], references: [id])
1452
+ value String //Always store as string, convert to other types in the application layer
1453
+
1454
+ node ElementNode @relation(fields: [nodeId], references: [id])
1455
+ nodeId String
1456
+
1457
+ @@index([nodeId])
1458
+ @@index([attributeDefId])
1357
1459
  }
1358
1460
 
1359
1461
  model Cable {
@@ -1403,6 +1505,9 @@ model Cable {
1403
1505
  project Project? @relation(fields: [projectId], references: [id])
1404
1506
  projectId String?
1405
1507
 
1508
+ node ElementNode? @relation(fields: [nodeId], references: [id])
1509
+ nodeId String?
1510
+
1406
1511
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
1407
1512
  installationId String?
1408
1513
 
@@ -1582,8 +1687,14 @@ model PboFat {
1582
1687
  cluster Cluster? @relation(fields: [clusterId], references: [id])
1583
1688
  clusterId String?
1584
1689
 
1690
+ node ElementNode? @relation(fields: [nodeId], references: [id])
1691
+ nodeId String?
1692
+
1585
1693
  dependencies PreviousEquipment[]
1586
1694
  Revision Revision[]
1695
+
1696
+ @@index([nodeId])
1697
+ @@index([clusterId])
1587
1698
  }
1588
1699
 
1589
1700
  model PboFatAttributes {
@@ -1663,6 +1774,9 @@ model SpliceClosure {
1663
1774
  cluster Cluster? @relation(fields: [clusterId], references: [id])
1664
1775
  clusterId String?
1665
1776
 
1777
+ node ElementNode? @relation(fields: [nodeId], references: [id])
1778
+ nodeId String?
1779
+
1666
1780
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
1667
1781
  installationId String?
1668
1782
 
@@ -1775,6 +1889,9 @@ model ZoneNro {
1775
1889
  cluster Cluster? @relation(fields: [clusterId], references: [id])
1776
1890
  clusterId String?
1777
1891
 
1892
+ node ElementNode? @relation(fields: [nodeId], references: [id])
1893
+ nodeId String?
1894
+
1778
1895
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
1779
1896
  installationId String?
1780
1897
 
@@ -1862,6 +1979,9 @@ model Pole {
1862
1979
  cluster Cluster? @relation(fields: [clusterId], references: [id])
1863
1980
  clusterId String?
1864
1981
 
1982
+ node ElementNode? @relation(fields: [nodeId], references: [id])
1983
+ nodeId String?
1984
+
1865
1985
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
1866
1986
  installationId String?
1867
1987
 
@@ -1949,6 +2069,9 @@ model Manhole {
1949
2069
  cluster Cluster? @relation(fields: [clusterId], references: [id])
1950
2070
  clusterId String?
1951
2071
 
2072
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2073
+ nodeId String?
2074
+
1952
2075
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
1953
2076
  installationId String?
1954
2077
 
@@ -2036,6 +2159,9 @@ model Loop {
2036
2159
  cluster Cluster? @relation(fields: [clusterId], references: [id])
2037
2160
  clusterId String?
2038
2161
 
2162
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2163
+ nodeId String?
2164
+
2039
2165
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
2040
2166
  installationId String?
2041
2167
 
@@ -2126,6 +2252,9 @@ model FDTSRO {
2126
2252
  cluster Cluster? @relation(fields: [clusterId], references: [id])
2127
2253
  clusterId String?
2128
2254
 
2255
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2256
+ nodeId String?
2257
+
2129
2258
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
2130
2259
  installationId String?
2131
2260
 
@@ -2214,6 +2343,9 @@ model SFU {
2214
2343
  cluster Cluster? @relation(fields: [clusterId], references: [id])
2215
2344
  clusterId String?
2216
2345
 
2346
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2347
+ nodeId String?
2348
+
2217
2349
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
2218
2350
  installationId String?
2219
2351
 
@@ -2307,6 +2439,9 @@ model Building {
2307
2439
  cluster Cluster? @relation(fields: [clusterId], references: [id])
2308
2440
  clusterId String?
2309
2441
 
2442
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2443
+ nodeId String?
2444
+
2310
2445
  installation NetworkElementInstallation? @relation(fields: [installationId], references: [id])
2311
2446
  installationId String?
2312
2447
 
@@ -2463,6 +2598,9 @@ model MapElement {
2463
2598
  cluster Cluster? @relation(fields: [clusterId], references: [id])
2464
2599
  clusterId String?
2465
2600
 
2601
+ node ElementNode? @relation(fields: [nodeId], references: [id])
2602
+ nodeId String?
2603
+
2466
2604
  qrCodeTag qrCodeTag[]
2467
2605
  }
2468
2606
 
@@ -2560,6 +2698,8 @@ model Cluster {
2560
2698
  MapElement MapElement[]
2561
2699
  ClusterComments ClusterComments[]
2562
2700
  Revision Revision[]
2701
+ ElementRelation ElementRelation[]
2702
+ ClusterNotes ClusterNotes[]
2563
2703
  }
2564
2704
 
2565
2705
  model ClusterComments {
@@ -2579,6 +2719,25 @@ model ClusterComments {
2579
2719
  clusterId String
2580
2720
  }
2581
2721
 
2722
+ model ClusterNotes {
2723
+ id String @id @unique @default(uuid())
2724
+ no Int @default(autoincrement())
2725
+
2726
+ comment String
2727
+ hasPicture Boolean @default(false)
2728
+ coordinates Json?
2729
+ picture String?
2730
+
2731
+ createdAt DateTime @default(now())
2732
+ updatedAt DateTime @updatedAt
2733
+
2734
+ createdBy User @relation(fields: [createdById], references: [id])
2735
+ createdById String
2736
+
2737
+ cluster Cluster @relation(fields: [clusterId], references: [id])
2738
+ clusterId String
2739
+ }
2740
+
2582
2741
  model CentralOfficeTeam {
2583
2742
  id String @id @unique @default(uuid())
2584
2743
  no Int @default(autoincrement())