@bslau/hmm_prisma_schema 1.13.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.13.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
@@ -138,10 +138,9 @@ model EventTorpedoMaintenance {
138
138
  updatedAt DateTime @updatedAt
139
139
  }
140
140
 
141
- /// **EVENT Torpedo On Gas**
141
+ /// **EVENT TORPEDO ON GAS**
142
142
  ///
143
143
  /// Capture when a torpedo is on gas and off gas.
144
-
145
144
  model EventTorpedoOnGas {
146
145
  id Int @id @default(autoincrement())
147
146
  event EventTracker @relation(fields: [eventId], references: [id])
@@ -154,6 +153,30 @@ model EventTorpedoOnGas {
154
153
  updatedAt DateTime @updatedAt
155
154
  }
156
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
+
157
180
  /// **EVENT TRACKER**
158
181
  ///
159
182
  /// Represents a generic system _Event_, which maps to its model instance.
@@ -166,6 +189,7 @@ model EventTracker {
166
189
  torpedoMovement EventTorpedoMovement?
167
190
  torpedoCapacity EventTorpedoCapacity?
168
191
  torpedoMaintenance EventTorpedoMaintenance?
192
+ torpedoState EventTorpedoState?
169
193
  eventTorpedoOnGas EventTorpedoOnGas?
170
194
  }
171
195
 
@@ -401,6 +425,7 @@ model Torpedo {
401
425
  eventTorpedoCapacity EventTorpedoCapacity[]
402
426
  eventTorpedoMaintenance EventTorpedoMaintenance[]
403
427
  eventsTorpedoOnGas EventTorpedoOnGas[]
428
+ eventsTorpedoState EventTorpedoState[]
404
429
  torpedoCampaign TorpedoCampaign[]
405
430
  torpedoCycle TorpedoCycle[]
406
431
  torpedoTrips TorpedoTrip[]
@@ -496,6 +521,7 @@ model TorpedoState {
496
521
  description String
497
522
  torpedoes Torpedo[]
498
523
  eventsTorpedoMovement EventTorpedoMovement[]
524
+ eventsTorpedoState EventTorpedoState[]
499
525
  }
500
526
 
501
527
  /// **TORPEDO TIMER**