@bslau/hmm_prisma_schema 1.3.0 → 1.3.2

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
@@ -6,8 +6,8 @@ The general workflow will follow these steps:
6
6
  - Edit `schema.prisma` as needed.
7
7
  - Run automated formatting: `npx prisma format`
8
8
  - Prepare database changes (as needed):
9
- - create (preview) migration: `npm prisma:create` or;
10
- - create and apply migration: `npm prisma:apply`
9
+ - create (preview) migration: `npm run prisma:create` or;
10
+ - create and apply migration: `npm run prisma:apply`
11
11
  - Update *minor* version number in `package.json`
12
12
  `"version": "[MAJOR].[MINOR].[PATCH]"`
13
13
  - Create and test new seeding function(s) if required - being cautious to avoid creating **duplicate** records on repeated runs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bslau/hmm_prisma_schema",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -0,0 +1,30 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- CreateTable
6
+ CREATE TABLE [dbo].[OperationalState] (
7
+ [id] INT NOT NULL IDENTITY(1,1),
8
+ [hotMetalPotTonnes] FLOAT(53) NOT NULL CONSTRAINT [OperationalState_hotMetalPotTonnes_df] DEFAULT 0,
9
+ [hotMetalTorpedoTonnes] FLOAT(53) NOT NULL CONSTRAINT [OperationalState_hotMetalTorpedoTonnes_df] DEFAULT 0,
10
+ [hotMetalTotalTonnes] FLOAT(53) NOT NULL CONSTRAINT [OperationalState_hotMetalTotalTonnes_df] DEFAULT 0,
11
+ [torpedoesActiveTally] INT NOT NULL CONSTRAINT [OperationalState_torpedoesActiveTally_df] DEFAULT 0,
12
+ [torpedoesAvailableTally] INT NOT NULL CONSTRAINT [OperationalState_torpedoesAvailableTally_df] DEFAULT 0,
13
+ [torpedoesCarryingTally] INT NOT NULL CONSTRAINT [OperationalState_torpedoesCarryingTally_df] DEFAULT 0,
14
+ [torpedoesStandbyTally] INT NOT NULL CONSTRAINT [OperationalState_torpedoesStandbyTally_df] DEFAULT 0,
15
+ [updatedAt] DATETIME2 NOT NULL,
16
+ CONSTRAINT [OperationalState_pkey] PRIMARY KEY CLUSTERED ([id])
17
+ );
18
+
19
+ COMMIT TRAN;
20
+
21
+ END TRY
22
+ BEGIN CATCH
23
+
24
+ IF @@TRANCOUNT > 0
25
+ BEGIN
26
+ ROLLBACK TRAN;
27
+ END;
28
+ THROW
29
+
30
+ END CATCH
@@ -0,0 +1,32 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[torpedoTripId]` on the table `EventTorpedoCapacity` will be added. If there are existing duplicate values, this will fail.
5
+ - Added the required column `torpedoTripId` to the `EventTorpedoCapacity` table without a default value. This is not possible if the table is not empty.
6
+
7
+ */
8
+ BEGIN TRY
9
+
10
+ BEGIN TRAN;
11
+
12
+ -- AlterTable
13
+ ALTER TABLE [dbo].[EventTorpedoCapacity] ADD [torpedoTripId] INT NOT NULL;
14
+
15
+ -- CreateIndex
16
+ ALTER TABLE [dbo].[EventTorpedoCapacity] ADD CONSTRAINT [EventTorpedoCapacity_torpedoTripId_key] UNIQUE NONCLUSTERED ([torpedoTripId]);
17
+
18
+ -- AddForeignKey
19
+ ALTER TABLE [dbo].[EventTorpedoCapacity] ADD CONSTRAINT [EventTorpedoCapacity_torpedoTripId_fkey] FOREIGN KEY ([torpedoTripId]) REFERENCES [dbo].[TorpedoTrip]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
20
+
21
+ COMMIT TRAN;
22
+
23
+ END TRY
24
+ BEGIN CATCH
25
+
26
+ IF @@TRANCOUNT > 0
27
+ BEGIN
28
+ ROLLBACK TRAN;
29
+ END;
30
+ THROW
31
+
32
+ END CATCH
@@ -131,6 +131,8 @@ model EventTorpedoCapacity {
131
131
  eventId Int @unique
132
132
  torpedoId Int
133
133
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
134
+ torpedoTrip TorpedoTrip @relation(fields: [torpedoTripId], references: [id])
135
+ torpedoTripId Int @unique
134
136
  capacityAverage Float
135
137
  dpLevelTldlManual Int
136
138
  createdAt DateTime @default(now())
@@ -455,6 +457,7 @@ model TorpedoTrip {
455
457
  hotMetalId Int
456
458
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: NoAction)
457
459
  torpedoId Int
460
+ eventTorpedoCapacity EventTorpedoCapacity?
458
461
  eventsTorpedoMovement EventTorpedoMovement[]
459
462
  startTime DateTime @default(now()) @db.DateTimeOffset
460
463
  endTime DateTime? @db.DateTimeOffset
package/prisma/seed.ts CHANGED
@@ -585,6 +585,19 @@ async function main() {
585
585
  createPot,
586
586
  });
587
587
  }
588
+
589
+ // SEED: OperationalState
590
+ if (await prisma.operationalState.count() > 0) {
591
+ console.log("SEED: OperationalState - skipped.");
592
+ } else {
593
+ console.log("SEED: OperationalState - generating...");
594
+
595
+ const createOperationalState = await prisma.operationalState.create({ data: {} });
596
+
597
+ console.log({
598
+ createOperationalState,
599
+ });
600
+ }
588
601
  }
589
602
 
590
603
  main()