@bslau/hmm_prisma_schema 1.1.19 → 1.1.21

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.1.19",
3
+ "version": "1.1.21",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -13,6 +13,7 @@
13
13
  "postinstall": "npm run generate",
14
14
  "prisma:apply": "npx prisma migrate dev",
15
15
  "prisma:create": "npx prisma migrate dev --create-only",
16
+ "prisma:deploy": "npx prisma migrate deploy",
16
17
  "test": "echo \"Error: no test specified\" && exit 1"
17
18
  },
18
19
  "types": "./index.d.ts",
@@ -0,0 +1,43 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- AlterTable
6
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD [torpedoCycleId] INT,
7
+ [torpedoStateId] INT NOT NULL CONSTRAINT [EventTorpedoMovement_torpedoStateId_df] DEFAULT 0,
8
+ [torpedoTripId] INT;
9
+
10
+ -- CreateTable
11
+ CREATE TABLE [dbo].[TorpedoCycle] (
12
+ [id] INT NOT NULL IDENTITY(1,1),
13
+ [hotMetalId] INT NOT NULL,
14
+ [torpedoId] INT NOT NULL,
15
+ [startTime] DATETIMEOFFSET NOT NULL CONSTRAINT [TorpedoCycle_startTime_df] DEFAULT CURRENT_TIMESTAMP,
16
+ [endTime] DATETIMEOFFSET,
17
+ CONSTRAINT [TorpedoCycle_pkey] PRIMARY KEY CLUSTERED ([id])
18
+ );
19
+
20
+ -- AddForeignKey
21
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_torpedoCycleId_fkey] FOREIGN KEY ([torpedoCycleId]) REFERENCES [dbo].[TorpedoCycle]([id]) ON DELETE SET NULL ON UPDATE CASCADE;
22
+
23
+ -- AddForeignKey
24
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_torpedoTripId_fkey] FOREIGN KEY ([torpedoTripId]) REFERENCES [dbo].[TorpedoTrip]([id]) ON DELETE SET NULL ON UPDATE CASCADE;
25
+
26
+ -- AddForeignKey
27
+ ALTER TABLE [dbo].[TorpedoCycle] ADD CONSTRAINT [TorpedoCycle_hotMetalId_fkey] FOREIGN KEY ([hotMetalId]) REFERENCES [dbo].[HotMetal]([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;
28
+
29
+ -- AddForeignKey
30
+ ALTER TABLE [dbo].[TorpedoCycle] ADD CONSTRAINT [TorpedoCycle_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE NO ACTION;
31
+
32
+ COMMIT TRAN;
33
+
34
+ END TRY
35
+ BEGIN CATCH
36
+
37
+ IF @@TRANCOUNT > 0
38
+ BEGIN
39
+ ROLLBACK TRAN;
40
+ END;
41
+ THROW
42
+
43
+ END CATCH
@@ -0,0 +1,35 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- CreateTable
6
+ CREATE TABLE [dbo].[EventTorpedoCapacity] (
7
+ [id] INT NOT NULL IDENTITY(1,1),
8
+ [eventId] INT NOT NULL,
9
+ [torpedoId] INT NOT NULL,
10
+ [capacityAverage] FLOAT(53) NOT NULL,
11
+ [dpLevelTldlManual] INT NOT NULL,
12
+ [createdAt] DATETIME2 NOT NULL CONSTRAINT [EventTorpedoCapacity_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
13
+ [updatedAt] DATETIME2 NOT NULL,
14
+ CONSTRAINT [EventTorpedoCapacity_pkey] PRIMARY KEY CLUSTERED ([id]),
15
+ CONSTRAINT [EventTorpedoCapacity_eventId_key] UNIQUE NONCLUSTERED ([eventId])
16
+ );
17
+
18
+ -- AddForeignKey
19
+ ALTER TABLE [dbo].[EventTorpedoCapacity] ADD CONSTRAINT [EventTorpedoCapacity_eventId_fkey] FOREIGN KEY ([eventId]) REFERENCES [dbo].[EventTracker]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
20
+
21
+ -- AddForeignKey
22
+ ALTER TABLE [dbo].[EventTorpedoCapacity] ADD CONSTRAINT [EventTorpedoCapacity_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
@@ -29,7 +29,7 @@ model CampaignRebricking {
29
29
  ///
30
30
  /// From OOS to OOS, used for _Torpedo Ladle_ refractory inspections, based on
31
31
  /// number of tonnes carried, typically carried out once or twice a year (on
32
- /// average). The total tonnes and _Trips_ on the lining are not reset.
32
+ /// average). The total tonnes and _Trips_ on the lining are not reset.
33
33
  model CampaignSurvey {
34
34
  id Int @id @default(autoincrement())
35
35
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
@@ -93,24 +93,48 @@ model Cast {
93
93
  /// **TORPEDO MOVEMENT EVENT**
94
94
  ///
95
95
  /// Capture the details of a _Torpedo Movement_ triggered by a **HMC Operator**.
96
+ ///
97
+ /// Each movement event captures the _Torpedo's_ operational _State_, and is
98
+ /// tracked within the context of the current _Trip_ and _Cycle_ - primarily for
99
+ /// reporting purposes.
96
100
  model EventTorpedoMovement {
97
- id Int @id @default(autoincrement())
101
+ id Int @id @default(autoincrement())
98
102
  torpedoId Int
99
- torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
100
- eventTime DateTime @db.DateTimeOffset
101
- originStation Station @relation(name: "originStation-movement", fields: [originStationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
103
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
104
+ torpedoStateId Int @default(0)
105
+ eventTime DateTime @db.DateTimeOffset
106
+ originStation Station @relation(name: "originStation-movement", fields: [originStationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
102
107
  originStationId Int
103
- originLocation Location @relation(name: "originLocation-movement", fields: [originLocationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
108
+ originLocation Location @relation(name: "originLocation-movement", fields: [originLocationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
104
109
  originLocationId Int
105
- destinationStation Station @relation(name: "destinationStation-movement", fields: [destinationStationId], references: [id], onDelete: NoAction, onUpdate: NoAction)
110
+ destinationStation Station @relation(name: "destinationStation-movement", fields: [destinationStationId], references: [id], onDelete: NoAction, onUpdate: NoAction)
106
111
  destinationStationId Int
107
- destinationLocation Location @relation(name: "destinationLocation-movement", fields: [destinationLocationId], references: [id], onDelete: NoAction, onUpdate: NoAction)
112
+ destinationLocation Location @relation(name: "destinationLocation-movement", fields: [destinationLocationId], references: [id], onDelete: NoAction, onUpdate: NoAction)
108
113
  destinationLocationId Int
109
- event EventTracker @relation(fields: [eventId], references: [id])
110
- eventId Int @unique
114
+ event EventTracker @relation(fields: [eventId], references: [id])
115
+ eventId Int @unique
111
116
  userId String?
112
- createdAt DateTime @default(now())
113
- updatedAt DateTime @updatedAt
117
+ torpedoCycle TorpedoCycle? @relation(fields: [torpedoCycleId], references: [id])
118
+ torpedoCycleId Int?
119
+ torpedoTrip TorpedoTrip? @relation(fields: [torpedoTripId], references: [id])
120
+ torpedoTripId Int?
121
+ createdAt DateTime @default(now())
122
+ updatedAt DateTime @updatedAt
123
+ }
124
+
125
+ /// **EVENT TORPEDO CAPACITY**
126
+ ///
127
+ /// Capture the input/output of the Capacity Calculation performed at the end of each Torpedo Trip.
128
+ model EventTorpedoCapacity {
129
+ id Int @id @default(autoincrement())
130
+ event EventTracker @relation(fields: [eventId], references: [id])
131
+ eventId Int @unique
132
+ torpedoId Int
133
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
134
+ capacityAverage Float
135
+ dpLevelTldlManual Int
136
+ createdAt DateTime @default(now())
137
+ updatedAt DateTime @updatedAt
114
138
  }
115
139
 
116
140
  /// **EVENT TRACKER**
@@ -122,6 +146,7 @@ model EventTracker {
122
146
  eventType String
123
147
  userId String?
124
148
  torpedoMovement EventTorpedoMovement?
149
+ torpedoCapacity EventTorpedoCapacity?
125
150
  }
126
151
 
127
152
  /// **HOT METAL HANDLER COMMENT**
@@ -141,7 +166,7 @@ model HMHComment {
141
166
  ///
142
167
  /// A (child) sub-lot, or batch, of molten iron produced by a **Blast Furnace**.
143
168
  ///
144
- /// Containes properties that describe when the _Hot Metal_ was produced and its
169
+ /// Contains properties that describe when the _Hot Metal_ was produced and its
145
170
  /// measured physical values.
146
171
  model HotMetal {
147
172
  id Int @id @default(autoincrement())
@@ -151,6 +176,7 @@ model HotMetal {
151
176
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
152
177
  torpedoId Int
153
178
  labResult HotMetalLabResult[]
179
+ torpedoCycle TorpedoCycle[]
154
180
  torpedoTrip TorpedoTrip[]
155
181
  dateTimeStartFill DateTime? @db.DateTimeOffset
156
182
  dateTimeEndFill DateTime? @db.DateTimeOffset
@@ -209,7 +235,7 @@ model HotMetal {
209
235
 
210
236
  /// **LAB RESULT**
211
237
  ///
212
- /// _Hot Meta_l testing data from the **LIMS** laboratory integration.
238
+ /// _Hot Metal_ testing data from the **LIMS** laboratory integration.
213
239
  ///
214
240
  /// Describes the time, type, and chemical analysis properties for a batch of
215
241
  /// _Hot Metal_. Samples are typically taken when filling at the **Blast Furnace**,
@@ -241,8 +267,8 @@ model HotMetalLabResult {
241
267
  ///
242
268
  /// An operational location where _Torpedoes_ may be placed during use.
243
269
  ///
244
- /// Within the context of HMM, a Location defines the physical place where a
245
- /// Torpedo is located, which is more precise than its Station.
270
+ /// Within the context of **HMM**, a _Location_ defines the physical place where a
271
+ /// _Torpedo_ is located, which is more precise than its _Station_.
246
272
  model Location {
247
273
  id Int @id @default(autoincrement())
248
274
  name String
@@ -307,8 +333,10 @@ model Torpedo {
307
333
  torpedoComments TorpedoComment[]
308
334
  hmhComments HMHComment[]
309
335
  eventsTorpedoMovement EventTorpedoMovement[]
336
+ eventTorpedoCapacity EventTorpedoCapacity[]
310
337
  campaignsRebricking CampaignRebricking[]
311
338
  campaignsSurvey CampaignSurvey[]
339
+ torpedoCycle TorpedoCycle[]
312
340
  torpedoTrips TorpedoTrip[]
313
341
  torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id])
314
342
  torpedoStateId Int?
@@ -329,6 +357,24 @@ model TorpedoComment {
329
357
  updatedAt DateTime? @updatedAt
330
358
  }
331
359
 
360
+ /// **TORPEDO CYCLE**
361
+ ///
362
+ /// Used to capture each period between consecutive _Torpedo_ filling events.
363
+ ///
364
+ /// Defined by:
365
+ /// - Start: **Blast Furnace** finish filling _Torpedo Ladle_
366
+ /// - End: Next **Blast Furnace** finish filling _Torpedo Ladle_
367
+ model TorpedoCycle {
368
+ id Int @id @default(autoincrement())
369
+ hotMetal HotMetal @relation(fields: [hotMetalId], references: [id], onDelete: NoAction, onUpdate: NoAction)
370
+ hotMetalId Int
371
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: NoAction)
372
+ torpedoId Int
373
+ eventsTorpedoMovement EventTorpedoMovement[]
374
+ startTime DateTime @default(now()) @db.DateTimeOffset
375
+ endTime DateTime? @db.DateTimeOffset
376
+ }
377
+
332
378
  /// **TORPEDO LOCATION**
333
379
  ///
334
380
  /// Defines the current operational _Location_ for each _Torpedo_.
@@ -365,18 +411,19 @@ model TorpedoState {
365
411
  /// The period between finishing a fill, and consuming that _Hot Metal_.
366
412
  ///
367
413
  /// Defined by:
368
- /// - Start: **Blast Furnace** finish filling ladle
414
+ /// - Start: **Blast Furnace** finish filling _Torpedo Ladle_
369
415
  /// - End: _Torpedo Ladle_ fully emptied at **BOS Weighbridge** or **21 Dump**
370
416
  model TorpedoTrip {
371
- id Int @id @default(autoincrement())
372
- campaignRebricking CampaignRebricking @relation(fields: [campaignRebrickingId], references: [id], onDelete: NoAction, onUpdate: NoAction)
373
- campaignRebrickingId Int
374
- campaignSurvey CampaignSurvey @relation(fields: [campaignSurveyId], references: [id], onDelete: NoAction, onUpdate: NoAction)
375
- campaignSurveyId Int
376
- hotMetal HotMetal @relation(fields: [hotMetalId], references: [id], onDelete: NoAction, onUpdate: NoAction)
377
- hotMetalId Int
378
- torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: NoAction)
379
- torpedoId Int
380
- startTime DateTime @default(now()) @db.DateTimeOffset
381
- endTime DateTime? @db.DateTimeOffset
417
+ id Int @id @default(autoincrement())
418
+ campaignRebricking CampaignRebricking @relation(fields: [campaignRebrickingId], references: [id], onDelete: NoAction, onUpdate: NoAction)
419
+ campaignRebrickingId Int
420
+ campaignSurvey CampaignSurvey @relation(fields: [campaignSurveyId], references: [id], onDelete: NoAction, onUpdate: NoAction)
421
+ campaignSurveyId Int
422
+ hotMetal HotMetal @relation(fields: [hotMetalId], references: [id], onDelete: NoAction, onUpdate: NoAction)
423
+ hotMetalId Int
424
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: NoAction)
425
+ torpedoId Int
426
+ eventsTorpedoMovement EventTorpedoMovement[]
427
+ startTime DateTime @default(now()) @db.DateTimeOffset
428
+ endTime DateTime? @db.DateTimeOffset
382
429
  }