@bslau/hmm_prisma_schema 1.1.13 → 1.1.15

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.
Files changed (30) hide show
  1. package/package.json +14 -8
  2. package/prisma/dbClient.ts +5 -0
  3. package/prisma/migrations/{20240910061111_init → 20250122012731_init}/migration.sql +74 -2
  4. package/prisma/migrations/20250127224749_test_column/migration.sql +25 -0
  5. package/prisma/migrations/20250127225625_delete_test_column/migration.sql +25 -0
  6. package/prisma/migrations/20250128232354_staion_location_models/migration.sql +85 -0
  7. package/prisma/migrations/20250129002847_staion_location_values_unique/migration.sql +29 -0
  8. package/prisma/migrations/migration_lock.toml +1 -1
  9. package/prisma/schema.prisma +33 -31
  10. package/prisma/seed.ts +545 -0
  11. package/script.ts +20 -0
  12. package/tsconfig.json +14 -0
  13. package/prisma/migrations/20240923010138_init/migration.sql +0 -32
  14. package/prisma/migrations/20240923011413_init/migration.sql +0 -37
  15. package/prisma/migrations/20240923013530_init/migration.sql +0 -32
  16. package/prisma/migrations/20240924014028_init/migration.sql +0 -27
  17. package/prisma/migrations/20241001001812_init/migration.sql +0 -19
  18. package/prisma/migrations/20241001003443_init/migration.sql +0 -28
  19. package/prisma/migrations/20241001004057_init/migration.sql +0 -29
  20. package/prisma/migrations/20241001005234_init/migration.sql +0 -28
  21. package/prisma/migrations/20241028055132_init/migration.sql +0 -46
  22. package/prisma/migrations/20241028223433_init/migration.sql +0 -52
  23. package/prisma/migrations/20241029041813_init/migration.sql +0 -55
  24. package/prisma/migrations/20241029044446_init/migration.sql +0 -78
  25. package/prisma/migrations/20241030045308_init/migration.sql +0 -19
  26. package/prisma/migrations/20241112005449_added_torpedo_properties_init/migration.sql +0 -31
  27. package/prisma/migrations/20241114030552_added_al_pucked_added/migration.sql +0 -19
  28. package/prisma/migrations/20241118235845_set_default_torpedo_status/migration.sql +0 -19
  29. package/prisma/migrations/20241119000008_set_default_torpedo_non_nullable/migration.sql +0 -25
  30. package/prisma/migrations/20241120022048_added_torpedo_comment/migration.sql +0 -20
package/package.json CHANGED
@@ -1,21 +1,27 @@
1
1
  {
2
2
  "name": "@bslau/hmm_prisma_schema",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
7
7
  "description": "HMM PRISMA Schema",
8
+ "prisma": {
9
+ "seed": "ts-node prisma/seed.ts"
10
+ },
8
11
  "scripts": {
9
12
  "generate": "npx prisma generate",
10
13
  "postinstall": "npm run generate",
11
14
  "test": "echo \"Error: no test specified\" && exit 1"
12
15
  },
16
+ "types": "./index.d.ts",
13
17
  "devDependencies": {
14
- "@prisma/client": "^5.18.0",
15
- "prisma": "^5.18.0"
16
- },
17
- "peerDependencies": {
18
- "@prisma/client": "5.18.0"
19
- },
20
- "types": "./index.d.ts"
18
+ "@prisma/client": "^6.2.1",
19
+ "@types/node": "^22.12.0",
20
+ "@types/underscore": "^1.13.0",
21
+ "prisma": "^6.2.1",
22
+ "ts-node": "^10.9.2",
23
+ "tsx": "^4.19.2",
24
+ "typescript": "^5.7.3",
25
+ "underscore": "^1.13.7"
26
+ }
21
27
  }
@@ -0,0 +1,5 @@
1
+ import { PrismaClient } from "@prisma/client";
2
+
3
+ const prisma = new PrismaClient();
4
+
5
+ export default prisma;
@@ -65,6 +65,9 @@ CREATE TABLE [dbo].[HotMetal] (
65
65
  [fillConstraintId] NVARCHAR(1000),
66
66
  [numberOfFillConstraints] INT,
67
67
  [massHotMetalAdded] INT,
68
+ [desulphurisationComplete] BIT NOT NULL CONSTRAINT [HotMetal_desulphurisationComplete_df] DEFAULT 0,
69
+ [containsPunchOut] BIT NOT NULL CONSTRAINT [HotMetal_containsPunchOut_df] DEFAULT 0,
70
+ [alPucksAdded] BIT NOT NULL CONSTRAINT [HotMetal_alPucksAdded_df] DEFAULT 0,
68
71
  [createdAt] DATETIME2 NOT NULL CONSTRAINT [HotMetal_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
69
72
  [updatedAt] DATETIME2 NOT NULL,
70
73
  CONSTRAINT [HotMetal_pkey] PRIMARY KEY CLUSTERED ([id]),
@@ -77,6 +80,15 @@ CREATE TABLE [dbo].[Torpedo] (
77
80
  [torpedoId] INT NOT NULL,
78
81
  [name] NVARCHAR(1000),
79
82
  [description] NVARCHAR(1000),
83
+ [futureLocation] NVARCHAR(1000),
84
+ [addAlPucksFlag] BIT NOT NULL CONSTRAINT [Torpedo_addAlPucksFlag_df] DEFAULT 0,
85
+ [heatUpFlag] BIT NOT NULL CONSTRAINT [Torpedo_heatUpFlag_df] DEFAULT 0,
86
+ [heatUpStartTime] DATETIMEOFFSET,
87
+ [onGasFlag] BIT NOT NULL CONSTRAINT [Torpedo_onGasFlag_df] DEFAULT 0,
88
+ [onGasEndDate] DATETIMEOFFSET,
89
+ [sixPitRestrictionFlag] BIT NOT NULL CONSTRAINT [Torpedo_sixPitRestrictionFlag_df] DEFAULT 0,
90
+ [sixPitRestrictionEndTime] DATETIMEOFFSET,
91
+ [status] INT NOT NULL CONSTRAINT [Torpedo_status_df] DEFAULT 2,
80
92
  [createdAt] DATETIME2 NOT NULL CONSTRAINT [Torpedo_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
81
93
  [updatedAt] DATETIME2 NOT NULL,
82
94
  CONSTRAINT [Torpedo_pkey] PRIMARY KEY CLUSTERED ([id]),
@@ -96,9 +108,11 @@ CREATE TABLE [dbo].[Station] (
96
108
  -- CreateTable
97
109
  CREATE TABLE [dbo].[HotMetalLabResult] (
98
110
  [id] INT NOT NULL IDENTITY(1,1),
111
+ [testSampleId] NVARCHAR(1000) NOT NULL,
99
112
  [hotMetalId] INT NOT NULL,
100
113
  [testDateTime] DATETIMEOFFSET NOT NULL,
101
- [sampleType] NVARCHAR(1000) NOT NULL,
114
+ [testSamplingLocation] NVARCHAR(1000),
115
+ [description] NVARCHAR(1000),
102
116
  [Si] FLOAT(53),
103
117
  [S] FLOAT(53),
104
118
  [P] FLOAT(53),
@@ -113,7 +127,7 @@ CREATE TABLE [dbo].[HotMetalLabResult] (
113
127
  [createdAt] DATETIME2 NOT NULL CONSTRAINT [HotMetalLabResult_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
114
128
  [updatedAt] DATETIME2 NOT NULL,
115
129
  CONSTRAINT [HotMetalLabResult_pkey] PRIMARY KEY CLUSTERED ([id]),
116
- CONSTRAINT [HotMetalLabResult_hotMetalId_key] UNIQUE NONCLUSTERED ([hotMetalId])
130
+ CONSTRAINT [HotMetalLabResult_testSampleId_key] UNIQUE NONCLUSTERED ([testSampleId] DESC)
117
131
  );
118
132
 
119
133
  -- CreateTable
@@ -138,6 +152,43 @@ CREATE TABLE [dbo].[TorpedoLocation] (
138
152
  CONSTRAINT [TorpedoLocation_torpedoId_key] UNIQUE NONCLUSTERED ([torpedoId])
139
153
  );
140
154
 
155
+ -- CreateTable
156
+ CREATE TABLE [dbo].[TorpedoComment] (
157
+ [id] INT NOT NULL IDENTITY(1,1),
158
+ [torpedoId] INT NOT NULL,
159
+ [comment] NVARCHAR(1000) NOT NULL,
160
+ [isCleared] BIT NOT NULL CONSTRAINT [TorpedoComment_isCleared_df] DEFAULT 0,
161
+ [createdAt] DATETIME2 NOT NULL CONSTRAINT [TorpedoComment_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
162
+ [updatedAt] DATETIME2,
163
+ CONSTRAINT [TorpedoComment_pkey] PRIMARY KEY CLUSTERED ([id])
164
+ );
165
+
166
+ -- CreateTable
167
+ CREATE TABLE [dbo].[EventTracker] (
168
+ [id] INT NOT NULL IDENTITY(1,1),
169
+ [eventTime] DATETIMEOFFSET NOT NULL,
170
+ [eventType] NVARCHAR(1000) NOT NULL,
171
+ [userId] NVARCHAR(1000),
172
+ CONSTRAINT [EventTracker_pkey] PRIMARY KEY CLUSTERED ([id])
173
+ );
174
+
175
+ -- CreateTable
176
+ CREATE TABLE [dbo].[EventTorpedoMovement] (
177
+ [id] INT NOT NULL IDENTITY(1,1),
178
+ [torpedoId] INT NOT NULL,
179
+ [eventTime] DATETIMEOFFSET NOT NULL,
180
+ [originStationId] INT NOT NULL,
181
+ [originSidingId] INT,
182
+ [destinationStationId] INT NOT NULL,
183
+ [destinationSidingId] INT,
184
+ [eventId] INT NOT NULL,
185
+ [userId] NVARCHAR(1000),
186
+ [createdAt] DATETIME2 NOT NULL CONSTRAINT [EventTorpedoMovement_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
187
+ [updatedAt] DATETIME2 NOT NULL,
188
+ CONSTRAINT [EventTorpedoMovement_pkey] PRIMARY KEY CLUSTERED ([id]),
189
+ CONSTRAINT [EventTorpedoMovement_eventId_key] UNIQUE NONCLUSTERED ([eventId])
190
+ );
191
+
141
192
  -- AddForeignKey
142
193
  ALTER TABLE [dbo].[HotMetal] ADD CONSTRAINT [HotMetal_castSequence_fkey] FOREIGN KEY ([castSequence]) REFERENCES [dbo].[Cast]([sequenceCastBlastFurnace]) ON DELETE NO ACTION ON UPDATE CASCADE;
143
194
 
@@ -156,6 +207,27 @@ ALTER TABLE [dbo].[TorpedoLocation] ADD CONSTRAINT [TorpedoLocation_torpedoId_fk
156
207
  -- AddForeignKey
157
208
  ALTER TABLE [dbo].[TorpedoLocation] ADD CONSTRAINT [TorpedoLocation_sidingId_fkey] FOREIGN KEY ([sidingId]) REFERENCES [dbo].[Siding]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
158
209
 
210
+ -- AddForeignKey
211
+ ALTER TABLE [dbo].[TorpedoComment] ADD CONSTRAINT [TorpedoComment_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE CASCADE;
212
+
213
+ -- AddForeignKey
214
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE CASCADE;
215
+
216
+ -- AddForeignKey
217
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_originStationId_fkey] FOREIGN KEY ([originStationId]) REFERENCES [dbo].[Station]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
218
+
219
+ -- AddForeignKey
220
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_originSidingId_fkey] FOREIGN KEY ([originSidingId]) REFERENCES [dbo].[Siding]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
221
+
222
+ -- AddForeignKey
223
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_destinationStationId_fkey] FOREIGN KEY ([destinationStationId]) REFERENCES [dbo].[Station]([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;
224
+
225
+ -- AddForeignKey
226
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_destinationSidingId_fkey] FOREIGN KEY ([destinationSidingId]) REFERENCES [dbo].[Siding]([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;
227
+
228
+ -- AddForeignKey
229
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_eventId_fkey] FOREIGN KEY ([eventId]) REFERENCES [dbo].[EventTracker]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
230
+
159
231
  COMMIT TRAN;
160
232
 
161
233
  END TRY
@@ -0,0 +1,25 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - Added the required column `test` to the `TorpedoComment` table without a default value. This is not possible if the table is not empty.
5
+
6
+ */
7
+ BEGIN TRY
8
+
9
+ BEGIN TRAN;
10
+
11
+ -- AlterTable
12
+ ALTER TABLE [dbo].[TorpedoComment] ADD [test] NVARCHAR(1000) NOT NULL;
13
+
14
+ COMMIT TRAN;
15
+
16
+ END TRY
17
+ BEGIN CATCH
18
+
19
+ IF @@TRANCOUNT > 0
20
+ BEGIN
21
+ ROLLBACK TRAN;
22
+ END;
23
+ THROW
24
+
25
+ END CATCH
@@ -0,0 +1,25 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `test` on the `TorpedoComment` table. All the data in the column will be lost.
5
+
6
+ */
7
+ BEGIN TRY
8
+
9
+ BEGIN TRAN;
10
+
11
+ -- AlterTable
12
+ ALTER TABLE [dbo].[TorpedoComment] DROP COLUMN [test];
13
+
14
+ COMMIT TRAN;
15
+
16
+ END TRY
17
+ BEGIN CATCH
18
+
19
+ IF @@TRANCOUNT > 0
20
+ BEGIN
21
+ ROLLBACK TRAN;
22
+ END;
23
+ THROW
24
+
25
+ END CATCH
@@ -0,0 +1,85 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `destinationSidingId` on the `EventTorpedoMovement` table. All the data in the column will be lost.
5
+ - You are about to drop the column `originSidingId` on the `EventTorpedoMovement` table. All the data in the column will be lost.
6
+ - You are about to drop the column `sidingId` on the `TorpedoLocation` table. All the data in the column will be lost.
7
+ - You are about to drop the `Siding` table. If the table is not empty, all the data it contains will be lost.
8
+ - Added the required column `destinationLocationId` to the `EventTorpedoMovement` table without a default value. This is not possible if the table is not empty.
9
+ - Added the required column `originLocationId` to the `EventTorpedoMovement` table without a default value. This is not possible if the table is not empty.
10
+ - Added the required column `locationId` to the `TorpedoLocation` table without a default value. This is not possible if the table is not empty.
11
+
12
+ */
13
+ BEGIN TRY
14
+
15
+ BEGIN TRAN;
16
+
17
+ -- DropForeignKey
18
+ ALTER TABLE [dbo].[EventTorpedoMovement] DROP CONSTRAINT [EventTorpedoMovement_destinationSidingId_fkey];
19
+
20
+ -- DropForeignKey
21
+ ALTER TABLE [dbo].[EventTorpedoMovement] DROP CONSTRAINT [EventTorpedoMovement_originSidingId_fkey];
22
+
23
+ -- DropForeignKey
24
+ ALTER TABLE [dbo].[TorpedoLocation] DROP CONSTRAINT [TorpedoLocation_sidingId_fkey];
25
+
26
+ -- AlterTable
27
+ ALTER TABLE [dbo].[EventTorpedoMovement] DROP COLUMN [destinationSidingId],
28
+ [originSidingId];
29
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD [destinationLocationId] INT NOT NULL,
30
+ [originLocationId] INT NOT NULL;
31
+
32
+ -- AlterTable
33
+ ALTER TABLE [dbo].[TorpedoLocation] DROP COLUMN [sidingId];
34
+ ALTER TABLE [dbo].[TorpedoLocation] ADD [locationId] INT NOT NULL;
35
+
36
+ -- DropTable
37
+ DROP TABLE [dbo].[Siding];
38
+
39
+ -- CreateTable
40
+ CREATE TABLE [dbo].[Location] (
41
+ [id] INT NOT NULL IDENTITY(1,1),
42
+ [name] NVARCHAR(1000) NOT NULL,
43
+ [value] NVARCHAR(1000) NOT NULL,
44
+ [createdAt] DATETIME2 NOT NULL CONSTRAINT [Location_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
45
+ [updatedAt] DATETIME2 NOT NULL,
46
+ CONSTRAINT [Location_pkey] PRIMARY KEY CLUSTERED ([id])
47
+ );
48
+
49
+ -- CreateTable
50
+ CREATE TABLE [dbo].[_LocationToStation] (
51
+ [A] INT NOT NULL,
52
+ [B] INT NOT NULL,
53
+ CONSTRAINT [_LocationToStation_AB_unique] UNIQUE NONCLUSTERED ([A],[B])
54
+ );
55
+
56
+ -- CreateIndex
57
+ CREATE NONCLUSTERED INDEX [_LocationToStation_B_index] ON [dbo].[_LocationToStation]([B]);
58
+
59
+ -- AddForeignKey
60
+ ALTER TABLE [dbo].[TorpedoLocation] ADD CONSTRAINT [TorpedoLocation_locationId_fkey] FOREIGN KEY ([locationId]) REFERENCES [dbo].[Location]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
61
+
62
+ -- AddForeignKey
63
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_originLocationId_fkey] FOREIGN KEY ([originLocationId]) REFERENCES [dbo].[Location]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
64
+
65
+ -- AddForeignKey
66
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_destinationLocationId_fkey] FOREIGN KEY ([destinationLocationId]) REFERENCES [dbo].[Location]([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;
67
+
68
+ -- AddForeignKey
69
+ ALTER TABLE [dbo].[_LocationToStation] ADD CONSTRAINT [_LocationToStation_A_fkey] FOREIGN KEY ([A]) REFERENCES [dbo].[Location]([id]) ON DELETE CASCADE ON UPDATE CASCADE;
70
+
71
+ -- AddForeignKey
72
+ ALTER TABLE [dbo].[_LocationToStation] ADD CONSTRAINT [_LocationToStation_B_fkey] FOREIGN KEY ([B]) REFERENCES [dbo].[Station]([id]) ON DELETE CASCADE ON UPDATE CASCADE;
73
+
74
+ COMMIT TRAN;
75
+
76
+ END TRY
77
+ BEGIN CATCH
78
+
79
+ IF @@TRANCOUNT > 0
80
+ BEGIN
81
+ ROLLBACK TRAN;
82
+ END;
83
+ THROW
84
+
85
+ END CATCH
@@ -0,0 +1,29 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[value]` on the table `Location` will be added. If there are existing duplicate values, this will fail.
5
+ - A unique constraint covering the columns `[value]` on the table `Station` will be added. If there are existing duplicate values, this will fail.
6
+
7
+ */
8
+ BEGIN TRY
9
+
10
+ BEGIN TRAN;
11
+
12
+ -- CreateIndex
13
+ ALTER TABLE [dbo].[Location] ADD CONSTRAINT [Location_value_key] UNIQUE NONCLUSTERED ([value]);
14
+
15
+ -- CreateIndex
16
+ ALTER TABLE [dbo].[Station] ADD CONSTRAINT [Station_value_key] UNIQUE NONCLUSTERED ([value]);
17
+
18
+ COMMIT TRAN;
19
+
20
+ END TRY
21
+ BEGIN CATCH
22
+
23
+ IF @@TRANCOUNT > 0
24
+ BEGIN
25
+ ROLLBACK TRAN;
26
+ END;
27
+ THROW
28
+
29
+ END CATCH
@@ -1,3 +1,3 @@
1
1
  # Please do not edit this file manually
2
- # It should be added in your version-control system (i.e. Git)
2
+ # It should be added in your version-control system (e.g., Git)
3
3
  provider = "mssql"
@@ -144,10 +144,11 @@ model Torpedo {
144
144
  model Station {
145
145
  id Int @id @default(autoincrement())
146
146
  name String
147
- value String
147
+ value String @unique
148
148
  createdAt DateTime @default(now())
149
149
  updatedAt DateTime @updatedAt
150
150
  torpedoLocations TorpedoLocation[]
151
+ locations Location[]
151
152
  eventsTorpedoMovementOrigin EventTorpedoMovement[] @relation(name: "originStation-movement")
152
153
  eventsTorpedoMovementDestination EventTorpedoMovement[] @relation(name: "destinationStation-movement")
153
154
  }
@@ -175,27 +176,28 @@ model HotMetalLabResult {
175
176
  updatedAt DateTime @updatedAt
176
177
  }
177
178
 
178
- model Siding {
179
+ model Location {
179
180
  id Int @id @default(autoincrement())
180
181
  name String
181
- value String
182
+ value String @unique
182
183
  createdAt DateTime @default(now())
183
184
  updatedAt DateTime @updatedAt
184
- eventsTorpedoMovementOrigin EventTorpedoMovement[] @relation(name: "originSiding-movement")
185
- eventsTorpedoMovementDestination EventTorpedoMovement[] @relation(name: "destinationSiding-movement")
185
+ eventsTorpedoMovementOrigin EventTorpedoMovement[] @relation(name: "originLocation-movement")
186
+ eventsTorpedoMovementDestination EventTorpedoMovement[] @relation(name: "destinationLocation-movement")
187
+ stations Station[]
186
188
  torpedoLocations TorpedoLocation[]
187
189
  }
188
190
 
189
191
  model TorpedoLocation {
190
- stationId Int
191
- station Station @relation(fields: [stationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
192
- position Int
193
- torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
194
- torpedoId Int @unique
195
- sidingId Int?
196
- siding Siding? @relation(fields: [sidingId], references: [id], onDelete: NoAction, onUpdate: Cascade)
197
- createdAt DateTime @default(now())
198
- updatedAt DateTime @updatedAt
192
+ stationId Int
193
+ station Station @relation(fields: [stationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
194
+ position Int
195
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
196
+ torpedoId Int @unique
197
+ locationId Int
198
+ location Location @relation(fields: [locationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
199
+ createdAt DateTime @default(now())
200
+ updatedAt DateTime @updatedAt
199
201
 
200
202
  @@id([stationId, position])
201
203
  }
@@ -219,21 +221,21 @@ model EventTracker {
219
221
  }
220
222
 
221
223
  model EventTorpedoMovement {
222
- id Int @id @default(autoincrement())
223
- torpedoId Int
224
- torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
225
- eventTime DateTime @db.DateTimeOffset
226
- originStation Station @relation(name: "originStation-movement", fields: [originStationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
227
- originStationId Int
228
- originSiding Siding? @relation(name: "originSiding-movement", fields: [originSidingId], references: [id], onDelete: NoAction, onUpdate: Cascade)
229
- originSidingId Int?
230
- destinationStation Station @relation(name: "destinationStation-movement", fields: [destinationStationId], references: [id], onDelete: NoAction, onUpdate: NoAction)
231
- destinationStationId Int
232
- destinationSiding Siding? @relation(name: "destinationSiding-movement", fields: [destinationSidingId], references: [id], onDelete: NoAction, onUpdate: NoAction)
233
- destinationSidingId Int?
234
- event EventTracker @relation(fields: [eventId], references: [id])
235
- eventId Int @unique
236
- userId String?
237
- createdAt DateTime @default(now())
238
- updatedAt DateTime @updatedAt
224
+ id Int @id @default(autoincrement())
225
+ torpedoId Int
226
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
227
+ eventTime DateTime @db.DateTimeOffset
228
+ originStation Station @relation(name: "originStation-movement", fields: [originStationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
229
+ originStationId Int
230
+ originLocation Location @relation(name: "originLocation-movement", fields: [originLocationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
231
+ originLocationId Int
232
+ destinationStation Station @relation(name: "destinationStation-movement", fields: [destinationStationId], references: [id], onDelete: NoAction, onUpdate: NoAction)
233
+ destinationStationId Int
234
+ destinationLocation Location @relation(name: "destinationLocation-movement", fields: [destinationLocationId], references: [id], onDelete: NoAction, onUpdate: NoAction)
235
+ destinationLocationId Int
236
+ event EventTracker @relation(fields: [eventId], references: [id])
237
+ eventId Int @unique
238
+ userId String?
239
+ createdAt DateTime @default(now())
240
+ updatedAt DateTime @updatedAt
239
241
  }