@bslau/hmm_prisma_schema 1.11.1 → 1.13.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.1",
3
+ "version": "1.13.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
@@ -0,0 +1,35 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- CreateTable
6
+ CREATE TABLE [dbo].[EventTorpedoOnGas] (
7
+ [id] INT NOT NULL IDENTITY(1,1),
8
+ [eventId] INT NOT NULL,
9
+ [torpedoId] INT NOT NULL,
10
+ [timerStart] DATETIMEOFFSET NOT NULL,
11
+ [timerEnd] DATETIMEOFFSET NOT NULL,
12
+ [createdAt] DATETIME2 NOT NULL CONSTRAINT [EventTorpedoOnGas_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
13
+ [updatedAt] DATETIME2 NOT NULL,
14
+ CONSTRAINT [EventTorpedoOnGas_pkey] PRIMARY KEY CLUSTERED ([id]),
15
+ CONSTRAINT [EventTorpedoOnGas_eventId_key] UNIQUE NONCLUSTERED ([eventId])
16
+ );
17
+
18
+ -- AddForeignKey
19
+ ALTER TABLE [dbo].[EventTorpedoOnGas] ADD CONSTRAINT [EventTorpedoOnGas_eventId_fkey] FOREIGN KEY ([eventId]) REFERENCES [dbo].[EventTracker]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
20
+
21
+ -- AddForeignKey
22
+ ALTER TABLE [dbo].[EventTorpedoOnGas] ADD CONSTRAINT [EventTorpedoOnGas_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE CASCADE;
23
+
24
+ COMMIT TRAN;
25
+
26
+ END TRY
27
+ BEGIN CATCH
28
+
29
+ IF @@TRANCOUNT > 0
30
+ BEGIN
31
+ ROLLBACK TRAN;
32
+ END;
33
+ THROW
34
+
35
+ END CATCH
@@ -138,6 +138,22 @@ model EventTorpedoMaintenance {
138
138
  updatedAt DateTime @updatedAt
139
139
  }
140
140
 
141
+ /// **EVENT Torpedo On Gas**
142
+ ///
143
+ /// Capture when a torpedo is on gas and off gas.
144
+
145
+ model EventTorpedoOnGas {
146
+ id Int @id @default(autoincrement())
147
+ event EventTracker @relation(fields: [eventId], references: [id])
148
+ eventId Int @unique
149
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
150
+ torpedoId Int
151
+ timerStart DateTime @db.DateTimeOffset
152
+ timerEnd DateTime @db.DateTimeOffset
153
+ createdAt DateTime @default(now())
154
+ updatedAt DateTime @updatedAt
155
+ }
156
+
141
157
  /// **EVENT TRACKER**
142
158
  ///
143
159
  /// Represents a generic system _Event_, which maps to its model instance.
@@ -150,6 +166,7 @@ model EventTracker {
150
166
  torpedoMovement EventTorpedoMovement?
151
167
  torpedoCapacity EventTorpedoCapacity?
152
168
  torpedoMaintenance EventTorpedoMaintenance?
169
+ eventTorpedoOnGas EventTorpedoOnGas?
153
170
  }
154
171
 
155
172
  /// **HOT METAL HANDLER COMMENT**
@@ -383,12 +400,14 @@ model Torpedo {
383
400
  eventsTorpedoMovement EventTorpedoMovement[]
384
401
  eventTorpedoCapacity EventTorpedoCapacity[]
385
402
  eventTorpedoMaintenance EventTorpedoMaintenance[]
403
+ eventsTorpedoOnGas EventTorpedoOnGas[]
386
404
  torpedoCampaign TorpedoCampaign[]
387
405
  torpedoCycle TorpedoCycle[]
388
406
  torpedoTrips TorpedoTrip[]
389
407
  notifications Notification[]
390
408
  torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id])
391
409
  torpedoStateId Int?
410
+ torpedoTimer TorpedoTimer?
392
411
  createdAt DateTime @default(now())
393
412
  updatedAt DateTime @updatedAt
394
413
  }
@@ -479,6 +498,31 @@ model TorpedoState {
479
498
  eventsTorpedoMovement EventTorpedoMovement[]
480
499
  }
481
500
 
501
+ /// **TORPEDO TIMER**
502
+ ///
503
+ /// Defines the _Timer_ that tracks and periodically checks specialized _Torpedo_ rules related to different time-based scenarios.
504
+ model TorpedoTimer {
505
+ id Int @id @default(autoincrement())
506
+ torpedo Torpedo @relation(fields: [torpedoId], references: [id], onDelete: NoAction, onUpdate: Cascade)
507
+ torpedoId Int @unique
508
+ torpedoTimerType TorpedoTimerType @relation(fields: [torpedoTimerTypeId], references: [id], onDelete: NoAction, onUpdate: Cascade)
509
+ torpedoTimerTypeId Int
510
+ startTime DateTime @default(now()) @db.DateTimeOffset
511
+ startTimeOffset Int @default(0)
512
+ createdAt DateTime @default(now())
513
+ updatedAt DateTime @updatedAt
514
+ }
515
+
516
+ /// **TORPEDO TIMER**
517
+ ///
518
+ /// Defines the type of a _TorpedoTimer_, can be HeatUp, OnGas, 6-Pit Swap, or 6-Pit Restriction
519
+ model TorpedoTimerType {
520
+ id Int @id @default(autoincrement())
521
+ name String
522
+ label String
523
+ torpedoTimers TorpedoTimer[]
524
+ }
525
+
482
526
  /// **TORPEDO TRIP (ON LINING)**
483
527
  ///
484
528
  /// The period between finishing a fill, and consuming that _Hot Metal_.
package/prisma/seed.ts CHANGED
@@ -590,6 +590,36 @@ async function main() {
590
590
  createHotMetalState,
591
591
  });
592
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
+ }
593
623
  }
594
624
 
595
625
  main()