@bslau/hmm_prisma_schema 1.1.18 → 1.1.19

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.19",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -11,6 +11,8 @@
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",
14
16
  "test": "echo \"Error: no test specified\" && exit 1"
15
17
  },
16
18
  "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
@@ -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,6 +90,9 @@ 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**.
56
96
  model EventTorpedoMovement {
57
97
  id Int @id @default(autoincrement())
58
98
  torpedoId Int
@@ -73,6 +113,9 @@ model EventTorpedoMovement {
73
113
  updatedAt DateTime @updatedAt
74
114
  }
75
115
 
116
+ /// **EVENT TRACKER**
117
+ ///
118
+ /// Represents a generic system _Event_, which maps to its model instance.
76
119
  model EventTracker {
77
120
  id Int @id @default(autoincrement())
78
121
  eventTime DateTime @db.DateTimeOffset
@@ -81,6 +124,9 @@ model EventTracker {
81
124
  torpedoMovement EventTorpedoMovement?
82
125
  }
83
126
 
127
+ /// **HOT METAL HANDLER COMMENT**
128
+ ///
129
+ /// Stores comments for specific _Torpedoes_, logged by **Maintenance Users**.
84
130
  model HMHComment {
85
131
  id Int @id @default(autoincrement())
86
132
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
@@ -91,6 +137,12 @@ model HMHComment {
91
137
  updatedAt DateTime? @updatedAt
92
138
  }
93
139
 
140
+ /// **HOT METAL**
141
+ ///
142
+ /// A (child) sub-lot, or batch, of molten iron produced by a **Blast Furnace**.
143
+ ///
144
+ /// Containes properties that describe when the _Hot Metal_ was produced and its
145
+ /// measured physical values.
94
146
  model HotMetal {
95
147
  id Int @id @default(autoincrement())
96
148
  mesId Int?
@@ -99,6 +151,7 @@ model HotMetal {
99
151
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
100
152
  torpedoId Int
101
153
  labResult HotMetalLabResult[]
154
+ torpedoTrip TorpedoTrip[]
102
155
  dateTimeStartFill DateTime? @db.DateTimeOffset
103
156
  dateTimeEndFill DateTime? @db.DateTimeOffset
104
157
  identityBlastFurnace Int
@@ -154,6 +207,13 @@ model HotMetal {
154
207
  @@unique(name: "cast_torpedo_id", [castSequence, torpedoId])
155
208
  }
156
209
 
210
+ /// **LAB RESULT**
211
+ ///
212
+ /// _Hot Meta_l testing data from the **LIMS** laboratory integration.
213
+ ///
214
+ /// Describes the time, type, and chemical analysis properties for a batch of
215
+ /// _Hot Metal_. Samples are typically taken when filling at the **Blast Furnace**,
216
+ /// and following **Desulphurisation** treatment(s).
157
217
  model HotMetalLabResult {
158
218
  id Int @id @default(autoincrement())
159
219
  testSampleId String @unique(sort: Desc)
@@ -177,6 +237,12 @@ model HotMetalLabResult {
177
237
  updatedAt DateTime @updatedAt
178
238
  }
179
239
 
240
+ /// **LOCATION**
241
+ ///
242
+ /// An operational location where _Torpedoes_ may be placed during use.
243
+ ///
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.
180
246
  model Location {
181
247
  id Int @id @default(autoincrement())
182
248
  name String
@@ -189,6 +255,12 @@ model Location {
189
255
  torpedoLocations TorpedoLocation[]
190
256
  }
191
257
 
258
+ /// **STATION**
259
+ ///
260
+ /// A logical location where different _Torpedo_ operations may occur.
261
+ ///
262
+ /// _Stations_ are logical groupings of physical locations that are linked based
263
+ /// on their (general) operational purpose.
192
264
  model Station {
193
265
  id Int @id @default(autoincrement())
194
266
  name String
@@ -201,6 +273,14 @@ model Station {
201
273
  eventsTorpedoMovementDestination EventTorpedoMovement[] @relation(name: "destinationStation-movement")
202
274
  }
203
275
 
276
+ /// **TORPEDO LADLE**
277
+ ///
278
+ /// Physical rail-based equipment used to carry _Hot Metal_ between _Locations_.
279
+ ///
280
+ /// _Torpedoes_ carry out work and undergo maintenance in their normal operation.
281
+ /// Their job is to get _Hot Metal_ from the **Blast Furnace(s)** to the **BOS**. The
282
+ /// system cares about how efficiently that's happening, and how much total
283
+ /// work they do.
204
284
  model Torpedo {
205
285
  id Int @id @default(autoincrement())
206
286
  torpedoId Int @unique(sort: Desc)
@@ -227,12 +307,18 @@ model Torpedo {
227
307
  torpedoComments TorpedoComment[]
228
308
  hmhComments HMHComment[]
229
309
  eventsTorpedoMovement EventTorpedoMovement[]
310
+ campaignsRebricking CampaignRebricking[]
311
+ campaignsSurvey CampaignSurvey[]
312
+ torpedoTrips TorpedoTrip[]
230
313
  torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id])
231
314
  torpedoStateId Int?
232
315
  createdAt DateTime @default(now())
233
316
  updatedAt DateTime @updatedAt
234
317
  }
235
318
 
319
+ /// **TORPEDO COMMENT**
320
+ ///
321
+ /// Stores comments for specific _Torpedoes_, logged by **HMC Operators**.
236
322
  model TorpedoComment {
237
323
  id Int @id @default(autoincrement())
238
324
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
@@ -243,6 +329,12 @@ model TorpedoComment {
243
329
  updatedAt DateTime? @updatedAt
244
330
  }
245
331
 
332
+ /// **TORPEDO LOCATION**
333
+ ///
334
+ /// Defines the current operational _Location_ for each _Torpedo_.
335
+ ///
336
+ /// The `position` property is only significant for _Stations_, representing
337
+ /// their physical sequence on the actual rail siding that they're occupying.
246
338
  model TorpedoLocation {
247
339
  stationId Int
248
340
  station Station @relation(fields: [stationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
@@ -257,6 +349,9 @@ model TorpedoLocation {
257
349
  @@id([stationId, position])
258
350
  }
259
351
 
352
+ /// **TORPEDO STATE**
353
+ ///
354
+ /// Describes a valid operational _State_ that a _Torpedo_ can be assigned.
260
355
  model TorpedoState {
261
356
  id Int @id @default(autoincrement())
262
357
  name String @unique
@@ -264,3 +359,24 @@ model TorpedoState {
264
359
  description String
265
360
  torpedoes Torpedo[]
266
361
  }
362
+
363
+ /// **TORPEDO TRIP (ON LINING)**
364
+ ///
365
+ /// The period between finishing a fill, and consuming that _Hot Metal_.
366
+ ///
367
+ /// Defined by:
368
+ /// - Start: **Blast Furnace** finish filling ladle
369
+ /// - End: _Torpedo Ladle_ fully emptied at **BOS Weighbridge** or **21 Dump**
370
+ 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
382
+ }