@bslau/hmm_prisma_schema 1.1.18 → 1.1.20

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.18",
3
+ "version": "1.1.20",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -11,6 +11,9 @@
11
11
  "scripts": {
12
12
  "generate": "npx prisma generate",
13
13
  "postinstall": "npm run generate",
14
+ "prisma:apply": "npx prisma migrate dev",
15
+ "prisma:create": "npx prisma migrate dev --create-only",
16
+ "prisma:deploy": "npx prisma migrate deploy",
14
17
  "test": "echo \"Error: no test specified\" && exit 1"
15
18
  },
16
19
  "types": "./index.d.ts",
@@ -0,0 +1,64 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- CreateTable
6
+ CREATE TABLE [dbo].[CampaignRebricking] (
7
+ [id] INT NOT NULL IDENTITY(1,1),
8
+ [torpedoId] INT NOT NULL,
9
+ [startTime] DATETIMEOFFSET NOT NULL CONSTRAINT [CampaignRebricking_startTime_df] DEFAULT CURRENT_TIMESTAMP,
10
+ [endTime] DATETIMEOFFSET,
11
+ CONSTRAINT [CampaignRebricking_pkey] PRIMARY KEY CLUSTERED ([id])
12
+ );
13
+
14
+ -- CreateTable
15
+ CREATE TABLE [dbo].[CampaignSurvey] (
16
+ [id] INT NOT NULL IDENTITY(1,1),
17
+ [torpedoId] INT NOT NULL,
18
+ [startTime] DATETIMEOFFSET NOT NULL CONSTRAINT [CampaignSurvey_startTime_df] DEFAULT CURRENT_TIMESTAMP,
19
+ [endTime] DATETIMEOFFSET,
20
+ CONSTRAINT [CampaignSurvey_pkey] PRIMARY KEY CLUSTERED ([id])
21
+ );
22
+
23
+ -- CreateTable
24
+ CREATE TABLE [dbo].[TorpedoTrip] (
25
+ [id] INT NOT NULL IDENTITY(1,1),
26
+ [campaignRebrickingId] INT NOT NULL,
27
+ [campaignSurveyId] INT NOT NULL,
28
+ [hotMetalId] INT NOT NULL,
29
+ [torpedoId] INT NOT NULL,
30
+ [startTime] DATETIMEOFFSET NOT NULL CONSTRAINT [TorpedoTrip_startTime_df] DEFAULT CURRENT_TIMESTAMP,
31
+ [endTime] DATETIMEOFFSET,
32
+ CONSTRAINT [TorpedoTrip_pkey] PRIMARY KEY CLUSTERED ([id])
33
+ );
34
+
35
+ -- AddForeignKey
36
+ ALTER TABLE [dbo].[CampaignRebricking] ADD CONSTRAINT [CampaignRebricking_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE CASCADE;
37
+
38
+ -- AddForeignKey
39
+ ALTER TABLE [dbo].[CampaignSurvey] ADD CONSTRAINT [CampaignSurvey_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE CASCADE;
40
+
41
+ -- AddForeignKey
42
+ ALTER TABLE [dbo].[TorpedoTrip] ADD CONSTRAINT [TorpedoTrip_campaignRebrickingId_fkey] FOREIGN KEY ([campaignRebrickingId]) REFERENCES [dbo].[CampaignRebricking]([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;
43
+
44
+ -- AddForeignKey
45
+ ALTER TABLE [dbo].[TorpedoTrip] ADD CONSTRAINT [TorpedoTrip_campaignSurveyId_fkey] FOREIGN KEY ([campaignSurveyId]) REFERENCES [dbo].[CampaignSurvey]([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;
46
+
47
+ -- AddForeignKey
48
+ ALTER TABLE [dbo].[TorpedoTrip] ADD CONSTRAINT [TorpedoTrip_hotMetalId_fkey] FOREIGN KEY ([hotMetalId]) REFERENCES [dbo].[HotMetal]([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;
49
+
50
+ -- AddForeignKey
51
+ ALTER TABLE [dbo].[TorpedoTrip] ADD CONSTRAINT [TorpedoTrip_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE NO ACTION;
52
+
53
+ COMMIT TRAN;
54
+
55
+ END TRY
56
+ BEGIN CATCH
57
+
58
+ IF @@TRANCOUNT > 0
59
+ BEGIN
60
+ ROLLBACK TRAN;
61
+ END;
62
+ THROW
63
+
64
+ END CATCH
@@ -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
@@ -8,6 +8,43 @@ datasource db {
8
8
  shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
9
9
  }
10
10
 
11
+ /// **REBRICKING CAMPAIGN**
12
+ ///
13
+ /// The entire lifespan of _Torpedo_ lining, from installation to removal.
14
+ ///
15
+ /// This indicates the entire refractory lining (or just working lining) is
16
+ /// removed and the tonnes and trips on the lining are reset.
17
+ model CampaignRebricking {
18
+ id Int @id @default(autoincrement())
19
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
20
+ torpedoId Int
21
+ torpedoTrips TorpedoTrip[]
22
+ startTime DateTime @default(now()) @db.DateTimeOffset
23
+ endTime DateTime? @db.DateTimeOffset
24
+ }
25
+
26
+ /// **SURVEY CAMPAIGN**
27
+ ///
28
+ /// A period of continual operation between OOS inspections (~2 annually).
29
+ ///
30
+ /// From OOS to OOS, used for _Torpedo Ladle_ refractory inspections, based on
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.
33
+ model CampaignSurvey {
34
+ id Int @id @default(autoincrement())
35
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
36
+ torpedoId Int
37
+ torpedoTrips TorpedoTrip[]
38
+ startTime DateTime @default(now()) @db.DateTimeOffset
39
+ endTime DateTime? @db.DateTimeOffset
40
+ }
41
+
42
+ /// **CAST**
43
+ ///
44
+ /// A (parent) lot of molten iron produced by a **Blast Furnace**.
45
+ ///
46
+ /// Contains properties that describe when the _Cast_ was produced and its
47
+ /// measured physical values.
11
48
  model Cast {
12
49
  id Int @id @default(autoincrement())
13
50
  sequenceCastBlastFurnace Int @unique(sort: Desc)
@@ -53,26 +90,41 @@ model Cast {
53
90
  hotMetalCollection HotMetal[]
54
91
  }
55
92
 
93
+ /// **TORPEDO MOVEMENT EVENT**
94
+ ///
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.
56
100
  model EventTorpedoMovement {
57
- id Int @id @default(autoincrement())
101
+ id Int @id @default(autoincrement())
58
102
  torpedoId Int
59
- torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
60
- eventTime DateTime @db.DateTimeOffset
61
- 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)
62
107
  originStationId Int
63
- 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)
64
109
  originLocationId Int
65
- 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)
66
111
  destinationStationId Int
67
- 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)
68
113
  destinationLocationId Int
69
- event EventTracker @relation(fields: [eventId], references: [id])
70
- eventId Int @unique
114
+ event EventTracker @relation(fields: [eventId], references: [id])
115
+ eventId Int @unique
71
116
  userId String?
72
- createdAt DateTime @default(now())
73
- 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
74
123
  }
75
124
 
125
+ /// **EVENT TRACKER**
126
+ ///
127
+ /// Represents a generic system _Event_, which maps to its model instance.
76
128
  model EventTracker {
77
129
  id Int @id @default(autoincrement())
78
130
  eventTime DateTime @db.DateTimeOffset
@@ -81,6 +133,9 @@ model EventTracker {
81
133
  torpedoMovement EventTorpedoMovement?
82
134
  }
83
135
 
136
+ /// **HOT METAL HANDLER COMMENT**
137
+ ///
138
+ /// Stores comments for specific _Torpedoes_, logged by **Maintenance Users**.
84
139
  model HMHComment {
85
140
  id Int @id @default(autoincrement())
86
141
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
@@ -91,6 +146,12 @@ model HMHComment {
91
146
  updatedAt DateTime? @updatedAt
92
147
  }
93
148
 
149
+ /// **HOT METAL**
150
+ ///
151
+ /// A (child) sub-lot, or batch, of molten iron produced by a **Blast Furnace**.
152
+ ///
153
+ /// Contains properties that describe when the _Hot Metal_ was produced and its
154
+ /// measured physical values.
94
155
  model HotMetal {
95
156
  id Int @id @default(autoincrement())
96
157
  mesId Int?
@@ -99,6 +160,8 @@ model HotMetal {
99
160
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
100
161
  torpedoId Int
101
162
  labResult HotMetalLabResult[]
163
+ torpedoCycle TorpedoCycle[]
164
+ torpedoTrip TorpedoTrip[]
102
165
  dateTimeStartFill DateTime? @db.DateTimeOffset
103
166
  dateTimeEndFill DateTime? @db.DateTimeOffset
104
167
  identityBlastFurnace Int
@@ -154,6 +217,13 @@ model HotMetal {
154
217
  @@unique(name: "cast_torpedo_id", [castSequence, torpedoId])
155
218
  }
156
219
 
220
+ /// **LAB RESULT**
221
+ ///
222
+ /// _Hot Metal_ testing data from the **LIMS** laboratory integration.
223
+ ///
224
+ /// Describes the time, type, and chemical analysis properties for a batch of
225
+ /// _Hot Metal_. Samples are typically taken when filling at the **Blast Furnace**,
226
+ /// and following **Desulphurisation** treatment(s).
157
227
  model HotMetalLabResult {
158
228
  id Int @id @default(autoincrement())
159
229
  testSampleId String @unique(sort: Desc)
@@ -177,6 +247,12 @@ model HotMetalLabResult {
177
247
  updatedAt DateTime @updatedAt
178
248
  }
179
249
 
250
+ /// **LOCATION**
251
+ ///
252
+ /// An operational location where _Torpedoes_ may be placed during use.
253
+ ///
254
+ /// Within the context of **HMM**, a _Location_ defines the physical place where a
255
+ /// _Torpedo_ is located, which is more precise than its _Station_.
180
256
  model Location {
181
257
  id Int @id @default(autoincrement())
182
258
  name String
@@ -189,6 +265,12 @@ model Location {
189
265
  torpedoLocations TorpedoLocation[]
190
266
  }
191
267
 
268
+ /// **STATION**
269
+ ///
270
+ /// A logical location where different _Torpedo_ operations may occur.
271
+ ///
272
+ /// _Stations_ are logical groupings of physical locations that are linked based
273
+ /// on their (general) operational purpose.
192
274
  model Station {
193
275
  id Int @id @default(autoincrement())
194
276
  name String
@@ -201,6 +283,14 @@ model Station {
201
283
  eventsTorpedoMovementDestination EventTorpedoMovement[] @relation(name: "destinationStation-movement")
202
284
  }
203
285
 
286
+ /// **TORPEDO LADLE**
287
+ ///
288
+ /// Physical rail-based equipment used to carry _Hot Metal_ between _Locations_.
289
+ ///
290
+ /// _Torpedoes_ carry out work and undergo maintenance in their normal operation.
291
+ /// Their job is to get _Hot Metal_ from the **Blast Furnace(s)** to the **BOS**. The
292
+ /// system cares about how efficiently that's happening, and how much total
293
+ /// work they do.
204
294
  model Torpedo {
205
295
  id Int @id @default(autoincrement())
206
296
  torpedoId Int @unique(sort: Desc)
@@ -227,12 +317,19 @@ model Torpedo {
227
317
  torpedoComments TorpedoComment[]
228
318
  hmhComments HMHComment[]
229
319
  eventsTorpedoMovement EventTorpedoMovement[]
320
+ campaignsRebricking CampaignRebricking[]
321
+ campaignsSurvey CampaignSurvey[]
322
+ torpedoCycle TorpedoCycle[]
323
+ torpedoTrips TorpedoTrip[]
230
324
  torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id])
231
325
  torpedoStateId Int?
232
326
  createdAt DateTime @default(now())
233
327
  updatedAt DateTime @updatedAt
234
328
  }
235
329
 
330
+ /// **TORPEDO COMMENT**
331
+ ///
332
+ /// Stores comments for specific _Torpedoes_, logged by **HMC Operators**.
236
333
  model TorpedoComment {
237
334
  id Int @id @default(autoincrement())
238
335
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
@@ -243,6 +340,30 @@ model TorpedoComment {
243
340
  updatedAt DateTime? @updatedAt
244
341
  }
245
342
 
343
+ /// **TORPEDO CYCLE**
344
+ ///
345
+ /// Used to capture each period between consecutive _Torpedo_ filling events.
346
+ ///
347
+ /// Defined by:
348
+ /// - Start: **Blast Furnace** finish filling _Torpedo Ladle_
349
+ /// - End: Next **Blast Furnace** finish filling _Torpedo Ladle_
350
+ model TorpedoCycle {
351
+ id Int @id @default(autoincrement())
352
+ hotMetal HotMetal @relation(fields: [hotMetalId], references: [id], onDelete: NoAction, onUpdate: NoAction)
353
+ hotMetalId Int
354
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: NoAction)
355
+ torpedoId Int
356
+ eventsTorpedoMovement EventTorpedoMovement[]
357
+ startTime DateTime @default(now()) @db.DateTimeOffset
358
+ endTime DateTime? @db.DateTimeOffset
359
+ }
360
+
361
+ /// **TORPEDO LOCATION**
362
+ ///
363
+ /// Defines the current operational _Location_ for each _Torpedo_.
364
+ ///
365
+ /// The `position` property is only significant for _Stations_, representing
366
+ /// their physical sequence on the actual rail siding that they're occupying.
246
367
  model TorpedoLocation {
247
368
  stationId Int
248
369
  station Station @relation(fields: [stationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
@@ -257,6 +378,9 @@ model TorpedoLocation {
257
378
  @@id([stationId, position])
258
379
  }
259
380
 
381
+ /// **TORPEDO STATE**
382
+ ///
383
+ /// Describes a valid operational _State_ that a _Torpedo_ can be assigned.
260
384
  model TorpedoState {
261
385
  id Int @id @default(autoincrement())
262
386
  name String @unique
@@ -264,3 +388,25 @@ model TorpedoState {
264
388
  description String
265
389
  torpedoes Torpedo[]
266
390
  }
391
+
392
+ /// **TORPEDO TRIP (ON LINING)**
393
+ ///
394
+ /// The period between finishing a fill, and consuming that _Hot Metal_.
395
+ ///
396
+ /// Defined by:
397
+ /// - Start: **Blast Furnace** finish filling _Torpedo Ladle_
398
+ /// - End: _Torpedo Ladle_ fully emptied at **BOS Weighbridge** or **21 Dump**
399
+ model TorpedoTrip {
400
+ id Int @id @default(autoincrement())
401
+ campaignRebricking CampaignRebricking @relation(fields: [campaignRebrickingId], references: [id], onDelete: NoAction, onUpdate: NoAction)
402
+ campaignRebrickingId Int
403
+ campaignSurvey CampaignSurvey @relation(fields: [campaignSurveyId], references: [id], onDelete: NoAction, onUpdate: NoAction)
404
+ campaignSurveyId Int
405
+ hotMetal HotMetal @relation(fields: [hotMetalId], references: [id], onDelete: NoAction, onUpdate: NoAction)
406
+ hotMetalId Int
407
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: NoAction)
408
+ torpedoId Int
409
+ eventsTorpedoMovement EventTorpedoMovement[]
410
+ startTime DateTime @default(now()) @db.DateTimeOffset
411
+ endTime DateTime? @db.DateTimeOffset
412
+ }