@bslau/hmm_prisma_schema 1.21.3 → 1.23.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/.prettierrc +4 -2
- package/package.json +1 -1
- package/prisma/migrations/20260408005312_create_table_to_store_unprocessed_messages/migration.sql +37 -0
- package/prisma/migrations/20260415004619_424963_hotmetal_mass/migration.sql +49 -0
- package/prisma/schema.prisma +50 -6
- package/prisma/seed.ts +79 -4
- package/tsconfig.json +10 -3
package/.prettierrc
CHANGED
package/package.json
CHANGED
package/prisma/migrations/20260408005312_create_table_to_store_unprocessed_messages/migration.sql
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
BEGIN TRY
|
|
2
|
+
|
|
3
|
+
BEGIN TRAN;
|
|
4
|
+
|
|
5
|
+
-- CreateTable
|
|
6
|
+
CREATE TABLE [dbo].[MessageFailedToProcess] (
|
|
7
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
8
|
+
[message] NVARCHAR(max) NOT NULL,
|
|
9
|
+
[messageTypeId] INT NOT NULL,
|
|
10
|
+
[reason] NVARCHAR(max) NOT NULL,
|
|
11
|
+
[isProcessed] BIT NOT NULL CONSTRAINT [MessageFailedToProcess_isProcessed_df] DEFAULT 0,
|
|
12
|
+
CONSTRAINT [MessageFailedToProcess_pkey] PRIMARY KEY CLUSTERED ([id])
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
-- CreateTable
|
|
16
|
+
CREATE TABLE [dbo].[MessageType] (
|
|
17
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
18
|
+
[name] NVARCHAR(1000) NOT NULL,
|
|
19
|
+
[label] NVARCHAR(1000) NOT NULL,
|
|
20
|
+
CONSTRAINT [MessageType_pkey] PRIMARY KEY CLUSTERED ([id])
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
-- AddForeignKey
|
|
24
|
+
ALTER TABLE [dbo].[MessageFailedToProcess] ADD CONSTRAINT [MessageFailedToProcess_messageTypeId_fkey] FOREIGN KEY ([messageTypeId]) REFERENCES [dbo].[MessageType]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
|
25
|
+
|
|
26
|
+
COMMIT TRAN;
|
|
27
|
+
|
|
28
|
+
END TRY
|
|
29
|
+
BEGIN CATCH
|
|
30
|
+
|
|
31
|
+
IF @@TRANCOUNT > 0
|
|
32
|
+
BEGIN
|
|
33
|
+
ROLLBACK TRAN;
|
|
34
|
+
END;
|
|
35
|
+
THROW
|
|
36
|
+
|
|
37
|
+
END CATCH
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
BEGIN TRY
|
|
2
|
+
|
|
3
|
+
BEGIN TRAN;
|
|
4
|
+
|
|
5
|
+
-- AlterTable
|
|
6
|
+
ALTER TABLE [dbo].[Torpedo] ADD [fillLevelPercentage] INT NOT NULL CONSTRAINT [Torpedo_fillLevelPercentage_df] DEFAULT 0;
|
|
7
|
+
|
|
8
|
+
-- AlterTable
|
|
9
|
+
ALTER TABLE [dbo].[TorpedoTrip] ADD [totalMass] FLOAT(53) NOT NULL CONSTRAINT [TorpedoTrip_totalMass_df] DEFAULT 0;
|
|
10
|
+
|
|
11
|
+
-- CreateTable
|
|
12
|
+
CREATE TABLE [dbo].[HotMetalMass] (
|
|
13
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
14
|
+
[mass] FLOAT(53) NOT NULL,
|
|
15
|
+
[hotMetalId] INT NOT NULL,
|
|
16
|
+
[hotMetalMassTypeId] INT NOT NULL,
|
|
17
|
+
[createdAt] DATETIME2 NOT NULL CONSTRAINT [HotMetalMass_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
|
|
18
|
+
[updatedAt] DATETIME2 NOT NULL,
|
|
19
|
+
CONSTRAINT [HotMetalMass_pkey] PRIMARY KEY CLUSTERED ([id])
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
-- CreateTable
|
|
23
|
+
CREATE TABLE [dbo].[HotMetalMassType] (
|
|
24
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
25
|
+
[name] NVARCHAR(1000) NOT NULL,
|
|
26
|
+
[label] NVARCHAR(1000) NOT NULL,
|
|
27
|
+
[type] NVARCHAR(1000) NOT NULL,
|
|
28
|
+
CONSTRAINT [HotMetalMassType_pkey] PRIMARY KEY CLUSTERED ([id]),
|
|
29
|
+
CONSTRAINT [HotMetalMassType_name_key] UNIQUE NONCLUSTERED ([name])
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
-- AddForeignKey
|
|
33
|
+
ALTER TABLE [dbo].[HotMetalMass] ADD CONSTRAINT [HotMetalMass_hotMetalId_fkey] FOREIGN KEY ([hotMetalId]) REFERENCES [dbo].[HotMetal]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
|
34
|
+
|
|
35
|
+
-- AddForeignKey
|
|
36
|
+
ALTER TABLE [dbo].[HotMetalMass] ADD CONSTRAINT [HotMetalMass_hotMetalMassTypeId_fkey] FOREIGN KEY ([hotMetalMassTypeId]) REFERENCES [dbo].[HotMetalMassType]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
|
37
|
+
|
|
38
|
+
COMMIT TRAN;
|
|
39
|
+
|
|
40
|
+
END TRY
|
|
41
|
+
BEGIN CATCH
|
|
42
|
+
|
|
43
|
+
IF @@TRANCOUNT > 0
|
|
44
|
+
BEGIN
|
|
45
|
+
ROLLBACK TRAN;
|
|
46
|
+
END;
|
|
47
|
+
THROW
|
|
48
|
+
|
|
49
|
+
END CATCH
|
package/prisma/schema.prisma
CHANGED
|
@@ -271,6 +271,7 @@ model HotMetal {
|
|
|
271
271
|
segmentResponseId String @unique
|
|
272
272
|
hotMetalState HotMetalState? @relation(fields: [hotMetalStateId], references: [id])
|
|
273
273
|
hotMetalStateId Int?
|
|
274
|
+
hotMetalMassCollection HotMetalMass[]
|
|
274
275
|
hotMetalPouredCollection HotMetalPoured[]
|
|
275
276
|
createdAt DateTime @default(now())
|
|
276
277
|
updatedAt DateTime @updatedAt
|
|
@@ -308,6 +309,35 @@ model HotMetalLabResult {
|
|
|
308
309
|
updatedAt DateTime @updatedAt
|
|
309
310
|
}
|
|
310
311
|
|
|
312
|
+
/// **HOT METAL MASS**
|
|
313
|
+
///
|
|
314
|
+
/// Provides information about when a _HotMetal_ batch mass is altered, what
|
|
315
|
+
/// type of change it was, and the mass of material that has been accounted
|
|
316
|
+
/// for. The intent is that these records form a history of a _HotMetal_
|
|
317
|
+
/// batch's mass alterations (whatever that may have been).
|
|
318
|
+
model HotMetalMass {
|
|
319
|
+
id Int @id @default(autoincrement())
|
|
320
|
+
mass Float
|
|
321
|
+
hotMetalId Int
|
|
322
|
+
hotMetal HotMetal @relation(references: [id], fields: [hotMetalId])
|
|
323
|
+
hotMetalMassType HotMetalMassType @relation(fields: [hotMetalMassTypeId], references: [id], onDelete: NoAction, onUpdate: Cascade)
|
|
324
|
+
hotMetalMassTypeId Int
|
|
325
|
+
createdAt DateTime @default(now())
|
|
326
|
+
updatedAt DateTime @updatedAt
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/// **HOT METAL MASS TYPE**
|
|
330
|
+
///
|
|
331
|
+
/// Defines the type of a _HotMetalMass_, which also indicates the type of
|
|
332
|
+
/// change to the batch - i.e. Addition, Subtraction, or new Total.
|
|
333
|
+
model HotMetalMassType {
|
|
334
|
+
id Int @id @default(autoincrement())
|
|
335
|
+
name String @unique
|
|
336
|
+
label String
|
|
337
|
+
type String // e.g. ADD, SUB, TOTAL
|
|
338
|
+
hotMetalMasses HotMetalMass[]
|
|
339
|
+
}
|
|
340
|
+
|
|
311
341
|
/// **HOT METAL POURED**
|
|
312
342
|
///
|
|
313
343
|
/// Provides information about when a _Hot Metal_ batch is poured, which _Pot_ it is poured into,
|
|
@@ -456,12 +486,9 @@ model Torpedo {
|
|
|
456
486
|
sixPitRestrictionFlag Boolean @default(false)
|
|
457
487
|
sixPitRestrictionEndTime DateTime? @db.DateTimeOffset
|
|
458
488
|
status Int @default(2)
|
|
459
|
-
// sixPitStart DateTime?
|
|
460
489
|
capacityAverage Float?
|
|
461
490
|
capacityNominal Float @default(200)
|
|
462
|
-
//
|
|
463
|
-
// emptyWeight Float?
|
|
464
|
-
// gasStart DateTime?
|
|
491
|
+
fillLevelPercentage Int @default(0) // e.g. 0, 50, 80, 100
|
|
465
492
|
hotMetalCollection HotMetal[]
|
|
466
493
|
torpedoLocation TorpedoLocation?
|
|
467
494
|
torpedoComments TorpedoComment[]
|
|
@@ -587,9 +614,9 @@ model TorpedoTimer {
|
|
|
587
614
|
@@unique(name: "torpedo_torpedoTimerType_id", [torpedoId, torpedoTimerTypeId])
|
|
588
615
|
}
|
|
589
616
|
|
|
590
|
-
/// **TORPEDO TIMER**
|
|
617
|
+
/// **TORPEDO TIMER TYPE**
|
|
591
618
|
///
|
|
592
|
-
/// Defines the type of a _TorpedoTimer_, can be HeatUp, OnGas, 6-Pit Swap, or 6-Pit Restriction
|
|
619
|
+
/// Defines the type of a _TorpedoTimer_, can be HeatUp, OnGas, 6-Pit Swap, or 6-Pit Restriction.
|
|
593
620
|
model TorpedoTimerType {
|
|
594
621
|
id Int @id @default(autoincrement())
|
|
595
622
|
name String
|
|
@@ -612,6 +639,7 @@ model TorpedoTrip {
|
|
|
612
639
|
torpedoId Int
|
|
613
640
|
torpedoCampaign TorpedoCampaign @relation(fields: [torpedoCampaignId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
614
641
|
torpedoCampaignId Int
|
|
642
|
+
totalMass Float @default(0)
|
|
615
643
|
eventTorpedoCapacity EventTorpedoCapacity?
|
|
616
644
|
eventsTorpedoMovement EventTorpedoMovement[]
|
|
617
645
|
startTime DateTime @default(now()) @db.DateTimeOffset
|
|
@@ -683,3 +711,19 @@ model NotificationSource {
|
|
|
683
711
|
label String
|
|
684
712
|
notifications Notification[]
|
|
685
713
|
}
|
|
714
|
+
|
|
715
|
+
model MessageFailedToProcess {
|
|
716
|
+
id Int @id @default(autoincrement())
|
|
717
|
+
message String @db.NVarChar(MAX)
|
|
718
|
+
messageTypeId Int
|
|
719
|
+
messageType MessageType @relation(fields: [messageTypeId], references: [id], onDelete: NoAction, onUpdate: Cascade)
|
|
720
|
+
reason String @db.NVarChar(MAX)
|
|
721
|
+
isProcessed Boolean @default(false)
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
model MessageType {
|
|
725
|
+
id Int @id @default(autoincrement())
|
|
726
|
+
name String
|
|
727
|
+
label String
|
|
728
|
+
messagesFailedToProcess MessageFailedToProcess[]
|
|
729
|
+
}
|
package/prisma/seed.ts
CHANGED
|
@@ -590,15 +590,15 @@ async function main() {
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
// SEED: TorpedoTimerType
|
|
593
|
-
if ((await prisma.torpedoTimerType.count()>0)
|
|
593
|
+
if ((await prisma.torpedoTimerType.count()) > 0) {
|
|
594
594
|
console.log("SEED: TorpedoTimerType - skipped.");
|
|
595
595
|
} else {
|
|
596
596
|
console.log("SEED: TorpedoTimerType - generating...");
|
|
597
597
|
|
|
598
|
-
const
|
|
598
|
+
const createTorpedoTimerTypes = await prisma.torpedoTimerType.createMany({
|
|
599
599
|
data: [
|
|
600
600
|
{
|
|
601
|
-
name:"Heat Up",
|
|
601
|
+
name: "Heat Up",
|
|
602
602
|
label: "Heat Up"
|
|
603
603
|
},
|
|
604
604
|
{
|
|
@@ -616,9 +616,84 @@ async function main() {
|
|
|
616
616
|
]
|
|
617
617
|
})
|
|
618
618
|
|
|
619
|
-
console.log({
|
|
619
|
+
console.log({createTorpedoTimerTypes})
|
|
620
620
|
}
|
|
621
621
|
|
|
622
|
+
// SEED: HotMetalMassType
|
|
623
|
+
if ((await prisma.hotMetalMassType.count()) > 0) {
|
|
624
|
+
console.log("SEED: HotMetalMassType - skipped.");
|
|
625
|
+
} else {
|
|
626
|
+
console.log("SEED: HotMetalMassType - generating...");
|
|
627
|
+
|
|
628
|
+
const createHotMetalMassTypes = await prisma.hotMetalMassType.createMany({
|
|
629
|
+
data: [
|
|
630
|
+
{
|
|
631
|
+
name: "6PIT_ReturnedSteel",
|
|
632
|
+
label: "6-Pit - Returned Steel",
|
|
633
|
+
type: "ADD",
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
name: "BF_EstimatedMassLevel",
|
|
637
|
+
label: "Blast Furnace - Estimated Mass (Level Calculation)",
|
|
638
|
+
type: "TOTAL",
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
name: "BF_EstimatedMassSupplied",
|
|
642
|
+
label: "Blast Furnace - Estimated Mass (Supplied Value)",
|
|
643
|
+
type: "TOTAL",
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
name: "DUMP_TorpedoEmpty",
|
|
647
|
+
label: "21 Dump - Torpedo Empty",
|
|
648
|
+
type: "SUB",
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
name: "WB_TorpedoPour",
|
|
652
|
+
label: "Weighbridge - Torpedo Pour",
|
|
653
|
+
type: "SUB",
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
name: "WB_TorpedoPourManual",
|
|
657
|
+
label: "Weighbridge - Torpedo Pour (Manual)",
|
|
658
|
+
type: "SUB",
|
|
659
|
+
},
|
|
660
|
+
],
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
console.log({createHotMetalMassTypes});
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (await prisma.messageType.count()>0) {
|
|
667
|
+
console.log("SEED: MessageType - skipped.");
|
|
668
|
+
}else {
|
|
669
|
+
console.log("SEED: MessageType - generating...");
|
|
670
|
+
|
|
671
|
+
const messageTypes = await prisma.messageType.createMany({
|
|
672
|
+
data: [
|
|
673
|
+
{
|
|
674
|
+
label: "CAST",
|
|
675
|
+
name: "Cast"
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
label: "TORPEDO_FILLING",
|
|
679
|
+
name: "Torpedo Filling"
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
label: "LIMS",
|
|
683
|
+
name: "Hot Metal Lab Result"
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
label: "WEIGHBRIDGE",
|
|
687
|
+
name: "BOS Weighbridge"
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
label: "POT_CONSUMED",
|
|
691
|
+
name: "Pot Consumed"
|
|
692
|
+
}
|
|
693
|
+
]
|
|
694
|
+
})
|
|
695
|
+
console.log(messageTypes)
|
|
696
|
+
}
|
|
622
697
|
}
|
|
623
698
|
|
|
624
699
|
main()
|
package/tsconfig.json
CHANGED
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2022",
|
|
4
4
|
"module": "CommonJS",
|
|
5
|
-
"lib": [
|
|
5
|
+
"lib": [
|
|
6
|
+
"ES2022"
|
|
7
|
+
],
|
|
6
8
|
"allowJs": true,
|
|
7
9
|
"outDir": "build",
|
|
10
|
+
"types": [
|
|
11
|
+
"node"
|
|
12
|
+
],
|
|
8
13
|
"strict": true,
|
|
9
14
|
"noImplicitAny": true,
|
|
10
15
|
"esModuleInterop": true,
|
|
11
16
|
"resolveJsonModule": true
|
|
12
17
|
},
|
|
13
|
-
"exclude": [
|
|
14
|
-
|
|
18
|
+
"exclude": [
|
|
19
|
+
"build"
|
|
20
|
+
]
|
|
21
|
+
}
|