efiber-prisma-schema 1.12.3 → 1.12.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.12.3",
3
+ "version": "1.12.5",
4
4
  "description": "Database schema for eFiber",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,95 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Project" ADD COLUMN "mapElementTemplateId" TEXT;
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "qrCodeTag" ADD COLUMN "mapElementId" TEXT;
6
+
7
+ -- AlterTable
8
+ ALTER TABLE "qrCodeTemplate" ADD COLUMN "mapElementTemplateId" TEXT;
9
+
10
+ -- CreateTable
11
+ CREATE TABLE "MapElementTemplate" (
12
+ "id" TEXT NOT NULL,
13
+ "no" SERIAL NOT NULL,
14
+ "status" TEXT NOT NULL DEFAULT 'active',
15
+ "name" TEXT,
16
+ "photos" JSONB,
17
+ "texts" JSONB,
18
+ "files" JSONB,
19
+ "zone" JSONB,
20
+ "geometry" JSONB,
21
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
22
+ "updatedAt" TIMESTAMP(3) NOT NULL,
23
+ "deletedAt" TIMESTAMP(3),
24
+ "updatedById" TEXT,
25
+ "networkElementId" TEXT NOT NULL,
26
+ "clusterId" TEXT,
27
+
28
+ CONSTRAINT "MapElementTemplate_pkey" PRIMARY KEY ("id")
29
+ );
30
+
31
+ -- CreateTable
32
+ CREATE TABLE "MapElement" (
33
+ "id" TEXT NOT NULL,
34
+ "no" SERIAL NOT NULL,
35
+ "status" TEXT NOT NULL DEFAULT 'active',
36
+ "name" TEXT,
37
+ "photos" JSONB,
38
+ "texts" JSONB,
39
+ "files" JSONB,
40
+ "zone" JSONB,
41
+ "geometry" JSONB,
42
+ "coordinates" JSONB,
43
+ "autoincrement" BOOLEAN NOT NULL DEFAULT true,
44
+ "namePrefix" TEXT,
45
+ "templateIndex" INTEGER,
46
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
47
+ "updatedAt" TIMESTAMP(3) NOT NULL,
48
+ "deletedAt" TIMESTAMP(3),
49
+ "updatedById" TEXT,
50
+ "networkElementId" TEXT NOT NULL,
51
+ "templateId" TEXT,
52
+ "projectId" TEXT,
53
+ "clusterId" TEXT,
54
+
55
+ CONSTRAINT "MapElement_pkey" PRIMARY KEY ("id")
56
+ );
57
+
58
+ -- CreateIndex
59
+ CREATE UNIQUE INDEX "MapElementTemplate_id_key" ON "MapElementTemplate"("id");
60
+
61
+ -- CreateIndex
62
+ CREATE UNIQUE INDEX "MapElement_id_key" ON "MapElement"("id");
63
+
64
+ -- AddForeignKey
65
+ ALTER TABLE "Project" ADD CONSTRAINT "Project_mapElementTemplateId_fkey" FOREIGN KEY ("mapElementTemplateId") REFERENCES "MapElementTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE;
66
+
67
+ -- AddForeignKey
68
+ ALTER TABLE "MapElementTemplate" ADD CONSTRAINT "MapElementTemplate_updatedById_fkey" FOREIGN KEY ("updatedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
69
+
70
+ -- AddForeignKey
71
+ ALTER TABLE "MapElementTemplate" ADD CONSTRAINT "MapElementTemplate_networkElementId_fkey" FOREIGN KEY ("networkElementId") REFERENCES "NetworkElement"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
72
+
73
+ -- AddForeignKey
74
+ ALTER TABLE "MapElementTemplate" ADD CONSTRAINT "MapElementTemplate_clusterId_fkey" FOREIGN KEY ("clusterId") REFERENCES "Cluster"("id") ON DELETE SET NULL ON UPDATE CASCADE;
75
+
76
+ -- AddForeignKey
77
+ ALTER TABLE "MapElement" ADD CONSTRAINT "MapElement_updatedById_fkey" FOREIGN KEY ("updatedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
78
+
79
+ -- AddForeignKey
80
+ ALTER TABLE "MapElement" ADD CONSTRAINT "MapElement_networkElementId_fkey" FOREIGN KEY ("networkElementId") REFERENCES "NetworkElement"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
81
+
82
+ -- AddForeignKey
83
+ ALTER TABLE "MapElement" ADD CONSTRAINT "MapElement_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "MapElementTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE;
84
+
85
+ -- AddForeignKey
86
+ ALTER TABLE "MapElement" ADD CONSTRAINT "MapElement_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE SET NULL ON UPDATE CASCADE;
87
+
88
+ -- AddForeignKey
89
+ ALTER TABLE "MapElement" ADD CONSTRAINT "MapElement_clusterId_fkey" FOREIGN KEY ("clusterId") REFERENCES "Cluster"("id") ON DELETE SET NULL ON UPDATE CASCADE;
90
+
91
+ -- AddForeignKey
92
+ ALTER TABLE "qrCodeTemplate" ADD CONSTRAINT "qrCodeTemplate_mapElementTemplateId_fkey" FOREIGN KEY ("mapElementTemplateId") REFERENCES "MapElementTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE;
93
+
94
+ -- AddForeignKey
95
+ ALTER TABLE "qrCodeTag" ADD CONSTRAINT "qrCodeTag_mapElementId_fkey" FOREIGN KEY ("mapElementId") REFERENCES "MapElement"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,8 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "MapElementType" AS ENUM ('Marker', 'Polyline', 'Polygon');
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "MapElement" ADD COLUMN "mapElementType" "MapElementType" NOT NULL DEFAULT 'Marker';
6
+
7
+ -- AlterTable
8
+ ALTER TABLE "MapElementTemplate" ADD COLUMN "mapElementType" "MapElementType" NOT NULL DEFAULT 'Marker';
@@ -0,0 +1,28 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `mapElementTemplateId` on the `Project` table. All the data in the column will be lost.
5
+
6
+ */
7
+ -- DropForeignKey
8
+ ALTER TABLE "Project" DROP CONSTRAINT "Project_mapElementTemplateId_fkey";
9
+
10
+ -- AlterTable
11
+ ALTER TABLE "Project" DROP COLUMN "mapElementTemplateId";
12
+
13
+ -- CreateTable
14
+ CREATE TABLE "_MapElementTemplateToProject" (
15
+ "A" TEXT NOT NULL,
16
+ "B" TEXT NOT NULL,
17
+
18
+ CONSTRAINT "_MapElementTemplateToProject_AB_pkey" PRIMARY KEY ("A","B")
19
+ );
20
+
21
+ -- CreateIndex
22
+ CREATE INDEX "_MapElementTemplateToProject_B_index" ON "_MapElementTemplateToProject"("B");
23
+
24
+ -- AddForeignKey
25
+ ALTER TABLE "_MapElementTemplateToProject" ADD CONSTRAINT "_MapElementTemplateToProject_A_fkey" FOREIGN KEY ("A") REFERENCES "MapElementTemplate"("id") ON DELETE CASCADE ON UPDATE CASCADE;
26
+
27
+ -- AddForeignKey
28
+ ALTER TABLE "_MapElementTemplateToProject" ADD CONSTRAINT "_MapElementTemplateToProject_B_fkey" FOREIGN KEY ("B") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -78,6 +78,12 @@ enum MetricType {
78
78
  FormulaResult
79
79
  }
80
80
 
81
+ enum MapElementType {
82
+ Marker
83
+ Polyline
84
+ Polygon
85
+ }
86
+
81
87
  model Country {
82
88
  id String @id @unique @default(uuid())
83
89
  no Int @default(autoincrement())
@@ -538,8 +544,7 @@ model Project {
538
544
  SFUTemplate SFUTemplate[]
539
545
  BuildingTemplate BuildingTemplate[]
540
546
  usersOnline integrationProjectUserStatus[]
541
- MapElementTemplate MapElementTemplate? @relation(fields: [mapElementTemplateId], references: [id])
542
- mapElementTemplateId String?
547
+ MapElementTemplate MapElementTemplate[]
543
548
  MapElement MapElement[]
544
549
  }
545
550
 
@@ -2233,6 +2238,8 @@ model MapElementTemplate {
2233
2238
  zone Json? //Color code for zone
2234
2239
  geometry Json? //Icon for the map element
2235
2240
 
2241
+ mapElementType MapElementType @default(Marker)
2242
+
2236
2243
  createdAt DateTime @default(now())
2237
2244
  updatedAt DateTime @updatedAt
2238
2245
  deletedAt DateTime?
@@ -2242,6 +2249,7 @@ model MapElementTemplate {
2242
2249
 
2243
2250
  networkElement NetworkElement @relation(fields: [networkElementId], references: [id])
2244
2251
  networkElementId String
2252
+
2245
2253
 
2246
2254
  projects Project[]
2247
2255
 
@@ -2267,6 +2275,8 @@ model MapElement {
2267
2275
  namePrefix String?
2268
2276
  templateIndex Int?
2269
2277
 
2278
+ mapElementType MapElementType @default(Marker)
2279
+
2270
2280
  createdAt DateTime @default(now())
2271
2281
  updatedAt DateTime @updatedAt
2272
2282
  deletedAt DateTime?