@bslau/hmm_prisma_schema 1.1.20 → 1.1.22

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/README.md CHANGED
@@ -11,8 +11,19 @@ TODO: Guide users through getting your code up and running on their own system.
11
11
  # Build and Test
12
12
  TODO: Describe and show how to build your code and run the tests.
13
13
 
14
- # Contribute
15
- TODO: Explain how other users and developers can contribute to make your code better.
14
+ # Edit prisma schema
15
+ TODO: Explain how other users and developers can edit prisma schema.
16
+ >create a branch
17
+
18
+ >edit schema.prisma
19
+
20
+ >npx prisma format
21
+
22
+ >npx prisma migrate dev --name new schema
23
+
24
+ >update version in package.json
25
+
26
+ >raise PR for merging to main branch
16
27
 
17
28
  If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
18
29
  - [ASP.NET Core](https://github.com/aspnet/Home)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bslau/hmm_prisma_schema",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -0,0 +1,35 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- CreateTable
6
+ CREATE TABLE [dbo].[EventTorpedoCapacity] (
7
+ [id] INT NOT NULL IDENTITY(1,1),
8
+ [eventId] INT NOT NULL,
9
+ [torpedoId] INT NOT NULL,
10
+ [capacityAverage] FLOAT(53) NOT NULL,
11
+ [dpLevelTldlManual] INT NOT NULL,
12
+ [createdAt] DATETIME2 NOT NULL CONSTRAINT [EventTorpedoCapacity_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
13
+ [updatedAt] DATETIME2 NOT NULL,
14
+ CONSTRAINT [EventTorpedoCapacity_pkey] PRIMARY KEY CLUSTERED ([id]),
15
+ CONSTRAINT [EventTorpedoCapacity_eventId_key] UNIQUE NONCLUSTERED ([eventId])
16
+ );
17
+
18
+ -- AddForeignKey
19
+ ALTER TABLE [dbo].[EventTorpedoCapacity] ADD CONSTRAINT [EventTorpedoCapacity_eventId_fkey] FOREIGN KEY ([eventId]) REFERENCES [dbo].[EventTracker]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
20
+
21
+ -- AddForeignKey
22
+ ALTER TABLE [dbo].[EventTorpedoCapacity] ADD CONSTRAINT [EventTorpedoCapacity_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
@@ -0,0 +1,19 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- AlterTable
6
+ ALTER TABLE [dbo].[HotMetal] ADD [potNumber] INT;
7
+
8
+ COMMIT TRAN;
9
+
10
+ END TRY
11
+ BEGIN CATCH
12
+
13
+ IF @@TRANCOUNT > 0
14
+ BEGIN
15
+ ROLLBACK TRAN;
16
+ END;
17
+ THROW
18
+
19
+ END CATCH
@@ -0,0 +1,37 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `potNumber` on the `HotMetal` table. All the data in the column will be lost.
5
+
6
+ */
7
+ BEGIN TRY
8
+
9
+ BEGIN TRAN;
10
+
11
+ -- AlterTable
12
+ ALTER TABLE [dbo].[HotMetal] DROP COLUMN [potNumber];
13
+ ALTER TABLE [dbo].[HotMetal] ADD [potId] INT;
14
+
15
+ -- CreateTable
16
+ CREATE TABLE [dbo].[Pot] (
17
+ [id] INT NOT NULL IDENTITY(1,1),
18
+ [name] NVARCHAR(1000) NOT NULL,
19
+ CONSTRAINT [Pot_pkey] PRIMARY KEY CLUSTERED ([id]),
20
+ CONSTRAINT [Pot_name_key] UNIQUE NONCLUSTERED ([name])
21
+ );
22
+
23
+ -- AddForeignKey
24
+ ALTER TABLE [dbo].[HotMetal] ADD CONSTRAINT [HotMetal_potId_fkey] FOREIGN KEY ([potId]) REFERENCES [dbo].[Pot]([id]) ON DELETE SET NULL 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
@@ -122,6 +122,21 @@ model EventTorpedoMovement {
122
122
  updatedAt DateTime @updatedAt
123
123
  }
124
124
 
125
+ /// **EVENT TORPEDO CAPACITY**
126
+ ///
127
+ /// Capture the input/output of the Capacity Calculation performed at the end of each Torpedo Trip.
128
+ model EventTorpedoCapacity {
129
+ id Int @id @default(autoincrement())
130
+ event EventTracker @relation(fields: [eventId], references: [id])
131
+ eventId Int @unique
132
+ torpedoId Int
133
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
134
+ capacityAverage Float
135
+ dpLevelTldlManual Int
136
+ createdAt DateTime @default(now())
137
+ updatedAt DateTime @updatedAt
138
+ }
139
+
125
140
  /// **EVENT TRACKER**
126
141
  ///
127
142
  /// Represents a generic system _Event_, which maps to its model instance.
@@ -131,6 +146,7 @@ model EventTracker {
131
146
  eventType String
132
147
  userId String?
133
148
  torpedoMovement EventTorpedoMovement?
149
+ torpedoCapacity EventTorpedoCapacity?
134
150
  }
135
151
 
136
152
  /// **HOT METAL HANDLER COMMENT**
@@ -176,6 +192,8 @@ model HotMetal {
176
192
  massHotMetalResidueTldl Int?
177
193
  massHotMetalTldlEstimated Int?
178
194
  massActual Int?
195
+ pot Pot? @relation(fields: [potId], references: [id])
196
+ potId Int?
179
197
  runRate Float?
180
198
  punchOut Boolean @default(false)
181
199
  plannedLevelFill Int?
@@ -317,6 +335,7 @@ model Torpedo {
317
335
  torpedoComments TorpedoComment[]
318
336
  hmhComments HMHComment[]
319
337
  eventsTorpedoMovement EventTorpedoMovement[]
338
+ eventTorpedoCapacity EventTorpedoCapacity[]
320
339
  campaignsRebricking CampaignRebricking[]
321
340
  campaignsSurvey CampaignSurvey[]
322
341
  torpedoCycle TorpedoCycle[]
@@ -410,3 +429,12 @@ model TorpedoTrip {
410
429
  startTime DateTime @default(now()) @db.DateTimeOffset
411
430
  endTime DateTime? @db.DateTimeOffset
412
431
  }
432
+
433
+ /// **POT**
434
+ ///
435
+ /// Pot Number is a property in Hot Metal Model.
436
+ model Pot {
437
+ id Int @id @default(autoincrement())
438
+ name String @unique
439
+ HotMetal HotMetal[]
440
+ }
package/prisma/seed.ts CHANGED
@@ -562,6 +562,29 @@ async function main() {
562
562
  createTorpedoState,
563
563
  });
564
564
  }
565
+
566
+ // SEED: Pot
567
+ if (await prisma.pot.count() > 0) {
568
+ console.log("SEED: Pot - skipped.");
569
+ } else {
570
+ console.log("SEED: Pot - generating...");
571
+
572
+ const createPot = await prisma.pot.createMany({
573
+ data: [
574
+ { name: "Pot 1"},
575
+ { name: "Pot 2"},
576
+ { name: "Pot 3"},
577
+ { name: "Pot 4"},
578
+ { name: "Pot 5"},
579
+ { name: "Pot 6"},
580
+ { name: "Pot 7"},
581
+ ],
582
+ });
583
+
584
+ console.log({
585
+ createPot,
586
+ });
587
+ }
565
588
  }
566
589
 
567
590
  main()