@bslau/hmm_prisma_schema 1.13.0 → 1.15.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
|
@@ -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,75 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `potId` on the `HotMetal` table. All the data in the column will be lost.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
BEGIN TRY
|
|
8
|
+
|
|
9
|
+
BEGIN TRAN;
|
|
10
|
+
|
|
11
|
+
-- DropForeignKey
|
|
12
|
+
ALTER TABLE [dbo].[HotMetal] DROP CONSTRAINT [HotMetal_potId_fkey];
|
|
13
|
+
|
|
14
|
+
-- AlterTable
|
|
15
|
+
ALTER TABLE [dbo].[HotMetal] DROP COLUMN [potId];
|
|
16
|
+
|
|
17
|
+
-- CreateTable
|
|
18
|
+
CREATE TABLE [dbo].[HotMetalPoured] (
|
|
19
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
20
|
+
[isDumped] BIT NOT NULL CONSTRAINT [HotMetalPoured_isDumped_df] DEFAULT 0,
|
|
21
|
+
[mass] FLOAT(53) NOT NULL,
|
|
22
|
+
[hotMetalId] INT NOT NULL,
|
|
23
|
+
[potId] INT,
|
|
24
|
+
[createdAt] DATETIME2 NOT NULL CONSTRAINT [HotMetalPoured_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
|
|
25
|
+
[updatedAt] DATETIME2 NOT NULL,
|
|
26
|
+
CONSTRAINT [HotMetalPoured_pkey] PRIMARY KEY CLUSTERED ([id])
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
-- CreateTable
|
|
30
|
+
CREATE TABLE [dbo].[PotMetal] (
|
|
31
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
32
|
+
[isConsumed] BIT NOT NULL CONSTRAINT [PotMetal_isConsumed_df] DEFAULT 0,
|
|
33
|
+
[dateConsumed] DATETIMEOFFSET NOT NULL,
|
|
34
|
+
[potId] INT NOT NULL,
|
|
35
|
+
[createdAt] DATETIME2 NOT NULL CONSTRAINT [PotMetal_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
|
|
36
|
+
[updatedAt] DATETIME2 NOT NULL,
|
|
37
|
+
CONSTRAINT [PotMetal_pkey] PRIMARY KEY CLUSTERED ([id])
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
-- CreateTable
|
|
41
|
+
CREATE TABLE [dbo].[PotMetalPoured] (
|
|
42
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
43
|
+
[isReturnedSteel] BIT NOT NULL CONSTRAINT [PotMetalPoured_isReturnedSteel_df] DEFAULT 0,
|
|
44
|
+
[mass] FLOAT(53) NOT NULL,
|
|
45
|
+
[potMetalId] INT NOT NULL,
|
|
46
|
+
[createdAt] DATETIME2 NOT NULL CONSTRAINT [PotMetalPoured_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
|
|
47
|
+
[updatedAt] DATETIME2 NOT NULL,
|
|
48
|
+
CONSTRAINT [PotMetalPoured_pkey] PRIMARY KEY CLUSTERED ([id]),
|
|
49
|
+
CONSTRAINT [PotMetalPoured_potMetalId_key] UNIQUE NONCLUSTERED ([potMetalId])
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
-- AddForeignKey
|
|
53
|
+
ALTER TABLE [dbo].[HotMetalPoured] ADD CONSTRAINT [HotMetalPoured_hotMetalId_fkey] FOREIGN KEY ([hotMetalId]) REFERENCES [dbo].[HotMetal]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
|
54
|
+
|
|
55
|
+
-- AddForeignKey
|
|
56
|
+
ALTER TABLE [dbo].[HotMetalPoured] ADD CONSTRAINT [HotMetalPoured_potId_fkey] FOREIGN KEY ([potId]) REFERENCES [dbo].[Pot]([id]) ON DELETE SET NULL ON UPDATE CASCADE;
|
|
57
|
+
|
|
58
|
+
-- AddForeignKey
|
|
59
|
+
ALTER TABLE [dbo].[PotMetal] ADD CONSTRAINT [PotMetal_potId_fkey] FOREIGN KEY ([potId]) REFERENCES [dbo].[Pot]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
|
60
|
+
|
|
61
|
+
-- AddForeignKey
|
|
62
|
+
ALTER TABLE [dbo].[PotMetalPoured] ADD CONSTRAINT [PotMetalPoured_potMetalId_fkey] FOREIGN KEY ([potMetalId]) REFERENCES [dbo].[PotMetal]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
|
63
|
+
|
|
64
|
+
COMMIT TRAN;
|
|
65
|
+
|
|
66
|
+
END TRY
|
|
67
|
+
BEGIN CATCH
|
|
68
|
+
|
|
69
|
+
IF @@TRANCOUNT > 0
|
|
70
|
+
BEGIN
|
|
71
|
+
ROLLBACK TRAN;
|
|
72
|
+
END;
|
|
73
|
+
THROW
|
|
74
|
+
|
|
75
|
+
END CATCH
|
package/prisma/schema.prisma
CHANGED
|
@@ -138,10 +138,9 @@ model EventTorpedoMaintenance {
|
|
|
138
138
|
updatedAt DateTime @updatedAt
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/// **EVENT
|
|
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
|
|
|
@@ -231,8 +255,6 @@ model HotMetal {
|
|
|
231
255
|
massHotMetalResidueTldl Int?
|
|
232
256
|
massHotMetalTldlEstimated Float?
|
|
233
257
|
massActual Int?
|
|
234
|
-
pot Pot? @relation(fields: [potId], references: [id])
|
|
235
|
-
potId Int?
|
|
236
258
|
runRate Float?
|
|
237
259
|
punchOut Boolean @default(false)
|
|
238
260
|
plannedLevelFill Int?
|
|
@@ -248,6 +270,7 @@ model HotMetal {
|
|
|
248
270
|
pourStatus Int @default(0)
|
|
249
271
|
hotMetalState HotMetalState? @relation(fields: [hotMetalStateId], references: [id])
|
|
250
272
|
hotMetalStateId Int?
|
|
273
|
+
hotMetalPouredCollection HotMetalPoured[]
|
|
251
274
|
createdAt DateTime @default(now())
|
|
252
275
|
updatedAt DateTime @updatedAt
|
|
253
276
|
|
|
@@ -284,6 +307,22 @@ model HotMetalLabResult {
|
|
|
284
307
|
updatedAt DateTime @updatedAt
|
|
285
308
|
}
|
|
286
309
|
|
|
310
|
+
/// **HOT METAL POURED**
|
|
311
|
+
///
|
|
312
|
+
/// Provides information about when a _Hot Metal_ batch is poured, which _Pot_ it is poured into,
|
|
313
|
+
/// and the mass of material that has been poured.
|
|
314
|
+
model HotMetalPoured {
|
|
315
|
+
id Int @id @default(autoincrement())
|
|
316
|
+
isDumped Boolean @default(false)
|
|
317
|
+
mass Float
|
|
318
|
+
hotMetalId Int
|
|
319
|
+
hotMetal HotMetal @relation(references: [id], fields: [hotMetalId])
|
|
320
|
+
potId Int?
|
|
321
|
+
pot Pot? @relation(references: [id], fields: [potId])
|
|
322
|
+
createdAt DateTime @default(now())
|
|
323
|
+
updatedAt DateTime @updatedAt
|
|
324
|
+
}
|
|
325
|
+
|
|
287
326
|
/// **HOT METAL STATE**
|
|
288
327
|
///
|
|
289
328
|
/// Describes a valid operational _State_ that a _HotMetal_ batch can be assigned.
|
|
@@ -338,9 +377,38 @@ model OperationalState {
|
|
|
338
377
|
///
|
|
339
378
|
/// Normal operations will "empty" a Torpedo's Hot Metal into a specific Pot.
|
|
340
379
|
model Pot {
|
|
341
|
-
id
|
|
342
|
-
name
|
|
343
|
-
|
|
380
|
+
id Int @id @default(autoincrement())
|
|
381
|
+
name String @unique
|
|
382
|
+
hotMetalPouredCollection HotMetalPoured[]
|
|
383
|
+
potMetalCollection PotMetal[]
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/// **POT METAL**
|
|
387
|
+
///
|
|
388
|
+
/// Represents the _Hot Metal_ poured into a pot, and tracks when the pot is emptied
|
|
389
|
+
model PotMetal {
|
|
390
|
+
id Int @id @default(autoincrement())
|
|
391
|
+
isConsumed Boolean @default(false)
|
|
392
|
+
dateConsumed DateTime @db.DateTimeOffset
|
|
393
|
+
potMetalPoured PotMetalPoured?
|
|
394
|
+
potId Int
|
|
395
|
+
pot Pot @relation(references: [id], fields: [potId])
|
|
396
|
+
createdAt DateTime @default(now())
|
|
397
|
+
updatedAt DateTime @updatedAt
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/// **POT METAL POURED**
|
|
401
|
+
///
|
|
402
|
+
/// Provides information about the pot when it is poured.
|
|
403
|
+
model PotMetalPoured {
|
|
404
|
+
id Int @id @default(autoincrement())
|
|
405
|
+
isReturnedSteel Boolean @default(false)
|
|
406
|
+
mass Float
|
|
407
|
+
potMetalId Int @unique
|
|
408
|
+
potMetal PotMetal @relation(references: [id], fields: [potMetalId])
|
|
409
|
+
|
|
410
|
+
createdAt DateTime @default(now())
|
|
411
|
+
updatedAt DateTime @updatedAt
|
|
344
412
|
}
|
|
345
413
|
|
|
346
414
|
/// **STATION**
|
|
@@ -401,6 +469,7 @@ model Torpedo {
|
|
|
401
469
|
eventTorpedoCapacity EventTorpedoCapacity[]
|
|
402
470
|
eventTorpedoMaintenance EventTorpedoMaintenance[]
|
|
403
471
|
eventsTorpedoOnGas EventTorpedoOnGas[]
|
|
472
|
+
eventsTorpedoState EventTorpedoState[]
|
|
404
473
|
torpedoCampaign TorpedoCampaign[]
|
|
405
474
|
torpedoCycle TorpedoCycle[]
|
|
406
475
|
torpedoTrips TorpedoTrip[]
|
|
@@ -496,6 +565,7 @@ model TorpedoState {
|
|
|
496
565
|
description String
|
|
497
566
|
torpedoes Torpedo[]
|
|
498
567
|
eventsTorpedoMovement EventTorpedoMovement[]
|
|
568
|
+
eventsTorpedoState EventTorpedoState[]
|
|
499
569
|
}
|
|
500
570
|
|
|
501
571
|
/// **TORPEDO TIMER**
|