@bslau/hmm_prisma_schema 1.12.0 → 1.14.0

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": "@bslau/hmm_prisma_schema",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -0,0 +1,38 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- CreateTable
6
+ CREATE TABLE [dbo].[EventTorpedoState] (
7
+ [id] INT NOT NULL IDENTITY(1,1),
8
+ [eventId] INT NOT NULL,
9
+ [torpedoId] INT NOT NULL,
10
+ [torpedoStateId] INT NOT NULL,
11
+ [changedAt] DATETIME2,
12
+ [createdAt] DATETIME2 NOT NULL CONSTRAINT [EventTorpedoState_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
13
+ [updatedAt] DATETIME2 NOT NULL,
14
+ CONSTRAINT [EventTorpedoState_pkey] PRIMARY KEY CLUSTERED ([id]),
15
+ CONSTRAINT [EventTorpedoState_eventId_key] UNIQUE NONCLUSTERED ([eventId])
16
+ );
17
+
18
+ -- AddForeignKey
19
+ ALTER TABLE [dbo].[EventTorpedoState] ADD CONSTRAINT [EventTorpedoState_eventId_fkey] FOREIGN KEY ([eventId]) REFERENCES [dbo].[EventTracker]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
20
+
21
+ -- AddForeignKey
22
+ ALTER TABLE [dbo].[EventTorpedoState] ADD CONSTRAINT [EventTorpedoState_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE CASCADE;
23
+
24
+ -- AddForeignKey
25
+ ALTER TABLE [dbo].[EventTorpedoState] ADD CONSTRAINT [EventTorpedoState_torpedoStateId_fkey] FOREIGN KEY ([torpedoStateId]) REFERENCES [dbo].[TorpedoState]([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;
26
+
27
+ COMMIT TRAN;
28
+
29
+ END TRY
30
+ BEGIN CATCH
31
+
32
+ IF @@TRANCOUNT > 0
33
+ BEGIN
34
+ ROLLBACK TRAN;
35
+ END;
36
+ THROW
37
+
38
+ END CATCH
@@ -0,0 +1,35 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- CreateTable
6
+ CREATE TABLE [dbo].[EventTorpedoOnGas] (
7
+ [id] INT NOT NULL IDENTITY(1,1),
8
+ [eventId] INT NOT NULL,
9
+ [torpedoId] INT NOT NULL,
10
+ [timerStart] DATETIMEOFFSET NOT NULL,
11
+ [timerEnd] DATETIMEOFFSET NOT NULL,
12
+ [createdAt] DATETIME2 NOT NULL CONSTRAINT [EventTorpedoOnGas_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
13
+ [updatedAt] DATETIME2 NOT NULL,
14
+ CONSTRAINT [EventTorpedoOnGas_pkey] PRIMARY KEY CLUSTERED ([id]),
15
+ CONSTRAINT [EventTorpedoOnGas_eventId_key] UNIQUE NONCLUSTERED ([eventId])
16
+ );
17
+
18
+ -- AddForeignKey
19
+ ALTER TABLE [dbo].[EventTorpedoOnGas] ADD CONSTRAINT [EventTorpedoOnGas_eventId_fkey] FOREIGN KEY ([eventId]) REFERENCES [dbo].[EventTracker]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
20
+
21
+ -- AddForeignKey
22
+ ALTER TABLE [dbo].[EventTorpedoOnGas] ADD CONSTRAINT [EventTorpedoOnGas_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE CASCADE;
23
+
24
+ COMMIT TRAN;
25
+
26
+ END TRY
27
+ BEGIN CATCH
28
+
29
+ IF @@TRANCOUNT > 0
30
+ BEGIN
31
+ ROLLBACK TRAN;
32
+ END;
33
+ THROW
34
+
35
+ END CATCH
@@ -138,6 +138,45 @@ model EventTorpedoMaintenance {
138
138
  updatedAt DateTime @updatedAt
139
139
  }
140
140
 
141
+ /// **EVENT TORPEDO ON GAS**
142
+ ///
143
+ /// Capture when a torpedo is on gas and off gas.
144
+ model EventTorpedoOnGas {
145
+ id Int @id @default(autoincrement())
146
+ event EventTracker @relation(fields: [eventId], references: [id])
147
+ eventId Int @unique
148
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
149
+ torpedoId Int
150
+ timerStart DateTime @db.DateTimeOffset
151
+ timerEnd DateTime @db.DateTimeOffset
152
+ createdAt DateTime @default(now())
153
+ updatedAt DateTime @updatedAt
154
+ }
155
+
156
+ /// **TORPEDO STATE-CHANGE EVENT**
157
+ ///
158
+ /// Capture the details of a _Torpedo State_ change event.
159
+ ///
160
+ /// It is necessary to keep a history of when each Torpedo's State is modified.
161
+ /// Whether that be by system or user triggered events. There are reporting
162
+ /// metrics for Torpedoes that depend on understanding the intervals that the
163
+ /// Torpedo exists in different Torpedo States.
164
+ ///
165
+ /// The "changedAt" property should be set at the time when the _next_ State
166
+ /// change happens.
167
+ model EventTorpedoState {
168
+ id Int @id @default(autoincrement())
169
+ event EventTracker @relation(fields: [eventId], references: [id])
170
+ eventId Int @unique
171
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
172
+ torpedoId Int
173
+ torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id], onDelete: NoAction, onUpdate: NoAction)
174
+ torpedoStateId Int
175
+ changedAt DateTime?
176
+ createdAt DateTime @default(now())
177
+ updatedAt DateTime @updatedAt
178
+ }
179
+
141
180
  /// **EVENT TRACKER**
142
181
  ///
143
182
  /// Represents a generic system _Event_, which maps to its model instance.
@@ -150,6 +189,8 @@ model EventTracker {
150
189
  torpedoMovement EventTorpedoMovement?
151
190
  torpedoCapacity EventTorpedoCapacity?
152
191
  torpedoMaintenance EventTorpedoMaintenance?
192
+ torpedoState EventTorpedoState?
193
+ eventTorpedoOnGas EventTorpedoOnGas?
153
194
  }
154
195
 
155
196
  /// **HOT METAL HANDLER COMMENT**
@@ -383,6 +424,8 @@ model Torpedo {
383
424
  eventsTorpedoMovement EventTorpedoMovement[]
384
425
  eventTorpedoCapacity EventTorpedoCapacity[]
385
426
  eventTorpedoMaintenance EventTorpedoMaintenance[]
427
+ eventsTorpedoOnGas EventTorpedoOnGas[]
428
+ eventsTorpedoState EventTorpedoState[]
386
429
  torpedoCampaign TorpedoCampaign[]
387
430
  torpedoCycle TorpedoCycle[]
388
431
  torpedoTrips TorpedoTrip[]
@@ -478,6 +521,7 @@ model TorpedoState {
478
521
  description String
479
522
  torpedoes Torpedo[]
480
523
  eventsTorpedoMovement EventTorpedoMovement[]
524
+ eventsTorpedoState EventTorpedoState[]
481
525
  }
482
526
 
483
527
  /// **TORPEDO TIMER**