@bslau/hmm_prisma_schema 1.11.0 → 1.12.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bslau/hmm_prisma_schema",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -29,4 +29,4 @@
29
29
  "typescript": "^5.7.3",
30
30
  "underscore": "^1.13.7"
31
31
  }
32
- }
32
+ }
@@ -0,0 +1,41 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- CreateTable
6
+ CREATE TABLE [dbo].[TorpedoTimer] (
7
+ [id] INT NOT NULL IDENTITY(1,1),
8
+ [torpedoId] INT NOT NULL,
9
+ [torpedoTimerTypeId] INT NOT NULL,
10
+ [startTime] DATETIMEOFFSET NOT NULL CONSTRAINT [TorpedoTimer_startTime_df] DEFAULT CURRENT_TIMESTAMP,
11
+ [startTimeOffset] INT NOT NULL CONSTRAINT [TorpedoTimer_startTimeOffset_df] DEFAULT 0,
12
+ CONSTRAINT [TorpedoTimer_pkey] PRIMARY KEY CLUSTERED ([id]),
13
+ CONSTRAINT [TorpedoTimer_torpedoId_key] UNIQUE NONCLUSTERED ([torpedoId])
14
+ );
15
+
16
+ -- CreateTable
17
+ CREATE TABLE [dbo].[TorpedoTimerType] (
18
+ [id] INT NOT NULL IDENTITY(1,1),
19
+ [name] NVARCHAR(1000) NOT NULL,
20
+ [label] NVARCHAR(1000) NOT NULL,
21
+ CONSTRAINT [TorpedoTimerType_pkey] PRIMARY KEY CLUSTERED ([id])
22
+ );
23
+
24
+ -- AddForeignKey
25
+ ALTER TABLE [dbo].[TorpedoTimer] ADD CONSTRAINT [TorpedoTimer_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
26
+
27
+ -- AddForeignKey
28
+ ALTER TABLE [dbo].[TorpedoTimer] ADD CONSTRAINT [TorpedoTimer_torpedoTimerTypeId_fkey] FOREIGN KEY ([torpedoTimerTypeId]) REFERENCES [dbo].[TorpedoTimerType]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
29
+
30
+ COMMIT TRAN;
31
+
32
+ END TRY
33
+ BEGIN CATCH
34
+
35
+ IF @@TRANCOUNT > 0
36
+ BEGIN
37
+ ROLLBACK TRAN;
38
+ END;
39
+ THROW
40
+
41
+ END CATCH
@@ -0,0 +1,26 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - Added the required column `updatedAt` to the `TorpedoTimer` table without a default value. This is not possible if the table is not empty.
5
+
6
+ */
7
+ BEGIN TRY
8
+
9
+ BEGIN TRAN;
10
+
11
+ -- AlterTable
12
+ ALTER TABLE [dbo].[TorpedoTimer] ADD [createdAt] DATETIME2 NOT NULL CONSTRAINT [TorpedoTimer_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
13
+ [updatedAt] DATETIME2 NOT NULL;
14
+
15
+ COMMIT TRAN;
16
+
17
+ END TRY
18
+ BEGIN CATCH
19
+
20
+ IF @@TRANCOUNT > 0
21
+ BEGIN
22
+ ROLLBACK TRAN;
23
+ END;
24
+ THROW
25
+
26
+ END CATCH
@@ -389,6 +389,7 @@ model Torpedo {
389
389
  notifications Notification[]
390
390
  torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id])
391
391
  torpedoStateId Int?
392
+ torpedoTimer TorpedoTimer?
392
393
  createdAt DateTime @default(now())
393
394
  updatedAt DateTime @updatedAt
394
395
  }
@@ -479,6 +480,31 @@ model TorpedoState {
479
480
  eventsTorpedoMovement EventTorpedoMovement[]
480
481
  }
481
482
 
483
+ /// **TORPEDO TIMER**
484
+ ///
485
+ /// Defines the _Timer_ that tracks and periodically checks specialized _Torpedo_ rules related to different time-based scenarios.
486
+ model TorpedoTimer {
487
+ id Int @id @default(autoincrement())
488
+ torpedo Torpedo @relation(fields: [torpedoId], references: [id], onDelete: NoAction, onUpdate: Cascade)
489
+ torpedoId Int @unique
490
+ torpedoTimerType TorpedoTimerType @relation(fields: [torpedoTimerTypeId], references: [id], onDelete: NoAction, onUpdate: Cascade)
491
+ torpedoTimerTypeId Int
492
+ startTime DateTime @default(now()) @db.DateTimeOffset
493
+ startTimeOffset Int @default(0)
494
+ createdAt DateTime @default(now())
495
+ updatedAt DateTime @updatedAt
496
+ }
497
+
498
+ /// **TORPEDO TIMER**
499
+ ///
500
+ /// Defines the type of a _TorpedoTimer_, can be HeatUp, OnGas, 6-Pit Swap, or 6-Pit Restriction
501
+ model TorpedoTimerType {
502
+ id Int @id @default(autoincrement())
503
+ name String
504
+ label String
505
+ torpedoTimers TorpedoTimer[]
506
+ }
507
+
482
508
  /// **TORPEDO TRIP (ON LINING)**
483
509
  ///
484
510
  /// The period between finishing a fill, and consuming that _Hot Metal_.
package/prisma/seed.ts CHANGED
@@ -493,6 +493,8 @@ async function main() {
493
493
  { name: "POT", label: "Pot" },
494
494
  { name: "CONDITION", label: "Condition" },
495
495
  { name: "OVERRIDDEN", label: "Overridden" },
496
+ { name: "TORPEDO_REJECTED", label: "Rejected" },
497
+ { name: "TORPEDO_UPDATED", label: "Data Update" },
496
498
  ],
497
499
  });
498
500
 
@@ -530,6 +532,11 @@ async function main() {
530
532
  label: "Snackbar",
531
533
  description: "Appears as snackbar, visible for 5 seconds.",
532
534
  },
535
+ {
536
+ name: "POPUP_TORPEDO_REJECT",
537
+ label: "Popup Torpedo Reject",
538
+ description: "Appears as modal dialog, requires user acknowledgement.",
539
+ },
533
540
  ],
534
541
  });
535
542
 
@@ -583,6 +590,36 @@ async function main() {
583
590
  createHotMetalState,
584
591
  });
585
592
  }
593
+
594
+ // SEED: TorpedoTimerType
595
+ if ((await prisma.torpedoTimerType.count()>0)) {
596
+ console.log("SEED: TorpedoTimerType - skipped.");
597
+ } else {
598
+ console.log("SEED: TorpedoTimerType - generating...");
599
+
600
+ const createTorpedoTimeTypes = await prisma.torpedoTimerType.createMany({
601
+ data: [
602
+ {
603
+ name:"Heat Up",
604
+ label: "Heat Up"
605
+ },
606
+ {
607
+ name: "On Gas",
608
+ label: "On Gas"
609
+ },
610
+ {
611
+ name: "6-Pit Swap",
612
+ label: "6-Pit Swap"
613
+ },
614
+ {
615
+ name:"6-Pit Restriction",
616
+ label:"6-Pit Restriction"
617
+ }
618
+ ]
619
+ })
620
+
621
+ console.log({createTorpedoTimeTypes})
622
+ }
586
623
  }
587
624
 
588
625
  main()