@bslau/hmm_prisma_schema 1.5.2 → 1.5.4

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.5.2",
3
+ "version": "1.5.4",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -16,8 +16,6 @@
16
16
  "prisma:deploy": "npx prisma migrate deploy",
17
17
  "prisma:seed": "npx prisma db seed",
18
18
  "prisma:format": "npx prisma format",
19
- "prettier:check": "npx prettier --check prisma",
20
- "prettier:write": "npx prettier --write prisma",
21
19
  "test": "echo \"Error: no test specified\" && exit 1"
22
20
  },
23
21
  "types": "./index.d.ts",
@@ -25,8 +23,6 @@
25
23
  "@prisma/client": "^6.2.1",
26
24
  "@types/node": "^22.12.0",
27
25
  "@types/underscore": "^1.13.0",
28
- "prettier": "^3.5.3",
29
- "prettier-plugin-prisma": "^5.0.0",
30
26
  "prisma": "^6.2.1",
31
27
  "ts-node": "^10.9.2",
32
28
  "tsx": "^4.19.2",
@@ -0,0 +1,29 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- CreateTable
6
+ CREATE TABLE [dbo].[EventTorpedoMaintenance] (
7
+ [id] INT NOT NULL IDENTITY(1,1),
8
+ [maintenanceDate] DATETIMEOFFSET NOT NULL,
9
+ [torpedoId] INT NOT NULL,
10
+ [createdAt] DATETIME2 NOT NULL CONSTRAINT [EventTorpedoMaintenance_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
11
+ [updatedAt] DATETIME2 NOT NULL,
12
+ CONSTRAINT [EventTorpedoMaintenance_pkey] PRIMARY KEY CLUSTERED ([id])
13
+ );
14
+
15
+ -- AddForeignKey
16
+ ALTER TABLE [dbo].[EventTorpedoMaintenance] ADD CONSTRAINT [EventTorpedoMaintenance_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE CASCADE;
17
+
18
+ COMMIT TRAN;
19
+
20
+ END TRY
21
+ BEGIN CATCH
22
+
23
+ IF @@TRANCOUNT > 0
24
+ BEGIN
25
+ ROLLBACK TRAN;
26
+ END;
27
+ THROW
28
+
29
+ END CATCH
@@ -0,0 +1,32 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[eventId]` on the table `EventTorpedoMaintenance` will be added. If there are existing duplicate values, this will fail.
5
+ - Added the required column `eventId` to the `EventTorpedoMaintenance` 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].[EventTorpedoMaintenance] ADD [eventId] INT NOT NULL;
14
+
15
+ -- CreateIndex
16
+ ALTER TABLE [dbo].[EventTorpedoMaintenance] ADD CONSTRAINT [EventTorpedoMaintenance_eventId_key] UNIQUE NONCLUSTERED ([eventId]);
17
+
18
+ -- AddForeignKey
19
+ ALTER TABLE [dbo].[EventTorpedoMaintenance] ADD CONSTRAINT [EventTorpedoMaintenance_eventId_fkey] FOREIGN KEY ([eventId]) REFERENCES [dbo].[EventTracker]([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
@@ -140,16 +140,31 @@ model EventTorpedoCapacity {
140
140
  updatedAt DateTime @updatedAt
141
141
  }
142
142
 
143
+ /// **EVENT TORPEDO MAINTENANCE**
144
+ ///
145
+ /// Capture when a Torpedo undergoes maintenance. (when a Torpedo is moved to the R+M Break Station for Maintenance.)
146
+ model EventTorpedoMaintenance {
147
+ id Int @id @default(autoincrement())
148
+ event EventTracker @relation(fields: [eventId], references: [id])
149
+ eventId Int @unique
150
+ maintenanceDate DateTime @db.DateTimeOffset
151
+ torpedoId Int
152
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
153
+ createdAt DateTime @default(now())
154
+ updatedAt DateTime @updatedAt
155
+ }
156
+
143
157
  /// **EVENT TRACKER**
144
158
  ///
145
159
  /// Represents a generic system _Event_, which maps to its model instance.
146
160
  model EventTracker {
147
- id Int @id @default(autoincrement())
148
- eventTime DateTime @db.DateTimeOffset
149
- eventType String
150
- userId String?
151
- torpedoMovement EventTorpedoMovement?
152
- torpedoCapacity EventTorpedoCapacity?
161
+ id Int @id @default(autoincrement())
162
+ eventTime DateTime @db.DateTimeOffset
163
+ eventType String
164
+ userId String?
165
+ torpedoMovement EventTorpedoMovement?
166
+ torpedoCapacity EventTorpedoCapacity?
167
+ torpedoMaintenance EventTorpedoMaintenance?
153
168
  }
154
169
 
155
170
  /// **HOT METAL HANDLER COMMENT**
@@ -345,23 +360,23 @@ model Station {
345
360
  /// system cares about how efficiently that's happening, and how much total
346
361
  /// work they do.
347
362
  model Torpedo {
348
- id Int @id @default(autoincrement())
349
- torpedoId Int @unique(sort: Desc)
363
+ id Int @id @default(autoincrement())
364
+ torpedoId Int @unique(sort: Desc)
350
365
  name String?
351
366
  description String?
352
367
  futureLocation String?
353
- addAlPucksFlag Boolean @default(false)
354
- heatUpFlag Boolean @default(false)
355
- heatUpStartTime DateTime? @db.DateTimeOffset
356
- onGasFlag Boolean @default(false)
357
- onGasEndDate DateTime? @db.DateTimeOffset
358
- hmhSixPitRestrictionFlag Boolean @default(false)
359
- sixPitRestrictionFlag Boolean @default(false)
360
- sixPitRestrictionEndTime DateTime? @db.DateTimeOffset
361
- status Int @default(2)
368
+ addAlPucksFlag Boolean @default(false)
369
+ heatUpFlag Boolean @default(false)
370
+ heatUpStartTime DateTime? @db.DateTimeOffset
371
+ onGasFlag Boolean @default(false)
372
+ onGasEndDate DateTime? @db.DateTimeOffset
373
+ hmhSixPitRestrictionFlag Boolean @default(false)
374
+ sixPitRestrictionFlag Boolean @default(false)
375
+ sixPitRestrictionEndTime DateTime? @db.DateTimeOffset
376
+ status Int @default(2)
362
377
  // sixPitStart DateTime?
363
378
  capacityAverage Float?
364
- capacityNominal Float @default(200)
379
+ capacityNominal Float @default(200)
365
380
  // comments String?
366
381
  // emptyWeight Float?
367
382
  // gasStart DateTime?
@@ -371,15 +386,16 @@ model Torpedo {
371
386
  hmhComments HMHComment[]
372
387
  eventsTorpedoMovement EventTorpedoMovement[]
373
388
  eventTorpedoCapacity EventTorpedoCapacity[]
389
+ eventTorpedoMaintenance EventTorpedoMaintenance[]
374
390
  campaignsRebricking CampaignRebricking[]
375
391
  campaignsSurvey CampaignSurvey[]
376
392
  torpedoCycle TorpedoCycle[]
377
393
  torpedoTrips TorpedoTrip[]
378
394
  notifications Notification[]
379
- torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id])
395
+ torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id])
380
396
  torpedoStateId Int?
381
- createdAt DateTime @default(now())
382
- updatedAt DateTime @updatedAt
397
+ createdAt DateTime @default(now())
398
+ updatedAt DateTime @updatedAt
383
399
  }
384
400
 
385
401
  /// **TORPEDO COMMENT**
package/prisma/seed.ts CHANGED
@@ -8,51 +8,50 @@ async function main() {
8
8
  } else {
9
9
  console.log("SEED: Torpedo - generating...");
10
10
 
11
- const createTorpedo =
12
- await prisma.torpedo.createMany({
13
- data: [
14
- { torpedoId: 18, name: "Torpedo 18", status: 2 },
15
- { torpedoId: 19, name: "Torpedo 19", status: 2 },
16
- { torpedoId: 20, name: "Torpedo 20", status: 2 },
17
- { torpedoId: 21, name: "Torpedo 21", status: 2 },
18
- { torpedoId: 22, name: "Torpedo 22", status: 2 },
19
- { torpedoId: 23, name: "Torpedo 23", status: 2 },
20
- { torpedoId: 24, name: "Torpedo 24", status: 2 },
21
- { torpedoId: 25, name: "Torpedo 25", status: 2 },
22
- { torpedoId: 27, name: "Torpedo 27", status: 2 },
23
- { torpedoId: 28, name: "Torpedo 28", status: 2 },
24
- { torpedoId: 29, name: "Torpedo 29", status: 2 },
25
- { torpedoId: 30, name: "Torpedo 30", status: 2 },
26
- { torpedoId: 31, name: "Torpedo 31", status: 2 },
27
- { torpedoId: 32, name: "Torpedo 32", status: 2 },
28
- { torpedoId: 33, name: "Torpedo 33", status: 2 },
29
- { torpedoId: 34, name: "Torpedo 34", status: 2 },
30
- { torpedoId: 35, name: "Torpedo 35", status: 2 },
31
- { torpedoId: 36, name: "Torpedo 36", status: 2 },
32
- { torpedoId: 37, name: "Torpedo 37", status: 2 },
33
- { torpedoId: 38, name: "Torpedo 38", status: 2 },
34
- { torpedoId: 39, name: "Torpedo 39", status: 2 },
35
- { torpedoId: 40, name: "Torpedo 40", status: 2 },
36
- { torpedoId: 41, name: "Torpedo 41", status: 2 },
37
- { torpedoId: 42, name: "Torpedo 42", status: 2 },
38
- { torpedoId: 43, name: "Torpedo 43", status: 2 },
39
- { torpedoId: 44, name: "Torpedo 44", status: 2 },
40
- { torpedoId: 45, name: "Torpedo 45", status: 2 },
41
- { torpedoId: 46, name: "Torpedo 46", status: 2 },
42
- { torpedoId: 47, name: "Torpedo 47", status: 2 },
43
- { torpedoId: 48, name: "Torpedo 48", status: 2 },
44
- { torpedoId: 49, name: "Torpedo 49", status: 2 },
45
- { torpedoId: 50, name: "Torpedo 50", status: 2 },
46
- { torpedoId: 51, name: "Torpedo 51", status: 2 },
47
- { torpedoId: 52, name: "Torpedo 52", status: 2 },
48
- { torpedoId: 54, name: "Torpedo 54", status: 2 },
49
- { torpedoId: 55, name: "Torpedo 55", status: 2 },
50
- { torpedoId: 56, name: "Torpedo 56", status: 2 },
51
- { torpedoId: 57, name: "Torpedo 57", status: 2 },
52
- { torpedoId: 58, name: "Torpedo 58", status: 2 },
53
- { torpedoId: 60, name: "Torpedo 60", status: 2 },
54
- ],
55
- });
11
+ const createTorpedo = await prisma.torpedo.createMany({
12
+ data: [
13
+ { torpedoId: 18, name: "Torpedo 18", status: 2 },
14
+ { torpedoId: 19, name: "Torpedo 19", status: 2 },
15
+ { torpedoId: 20, name: "Torpedo 20", status: 2 },
16
+ { torpedoId: 21, name: "Torpedo 21", status: 2 },
17
+ { torpedoId: 22, name: "Torpedo 22", status: 2 },
18
+ { torpedoId: 23, name: "Torpedo 23", status: 2 },
19
+ { torpedoId: 24, name: "Torpedo 24", status: 2 },
20
+ { torpedoId: 25, name: "Torpedo 25", status: 2 },
21
+ { torpedoId: 27, name: "Torpedo 27", status: 2 },
22
+ { torpedoId: 28, name: "Torpedo 28", status: 2 },
23
+ { torpedoId: 29, name: "Torpedo 29", status: 2 },
24
+ { torpedoId: 30, name: "Torpedo 30", status: 2 },
25
+ { torpedoId: 31, name: "Torpedo 31", status: 2 },
26
+ { torpedoId: 32, name: "Torpedo 32", status: 2 },
27
+ { torpedoId: 33, name: "Torpedo 33", status: 2 },
28
+ { torpedoId: 34, name: "Torpedo 34", status: 2 },
29
+ { torpedoId: 35, name: "Torpedo 35", status: 2 },
30
+ { torpedoId: 36, name: "Torpedo 36", status: 2 },
31
+ { torpedoId: 37, name: "Torpedo 37", status: 2 },
32
+ { torpedoId: 38, name: "Torpedo 38", status: 2 },
33
+ { torpedoId: 39, name: "Torpedo 39", status: 2 },
34
+ { torpedoId: 40, name: "Torpedo 40", status: 2 },
35
+ { torpedoId: 41, name: "Torpedo 41", status: 2 },
36
+ { torpedoId: 42, name: "Torpedo 42", status: 2 },
37
+ { torpedoId: 43, name: "Torpedo 43", status: 2 },
38
+ { torpedoId: 44, name: "Torpedo 44", status: 2 },
39
+ { torpedoId: 45, name: "Torpedo 45", status: 2 },
40
+ { torpedoId: 46, name: "Torpedo 46", status: 2 },
41
+ { torpedoId: 47, name: "Torpedo 47", status: 2 },
42
+ { torpedoId: 48, name: "Torpedo 48", status: 2 },
43
+ { torpedoId: 49, name: "Torpedo 49", status: 2 },
44
+ { torpedoId: 50, name: "Torpedo 50", status: 2 },
45
+ { torpedoId: 51, name: "Torpedo 51", status: 2 },
46
+ { torpedoId: 52, name: "Torpedo 52", status: 2 },
47
+ { torpedoId: 54, name: "Torpedo 54", status: 2 },
48
+ { torpedoId: 55, name: "Torpedo 55", status: 2 },
49
+ { torpedoId: 56, name: "Torpedo 56", status: 2 },
50
+ { torpedoId: 57, name: "Torpedo 57", status: 2 },
51
+ { torpedoId: 58, name: "Torpedo 58", status: 2 },
52
+ { torpedoId: 60, name: "Torpedo 60", status: 2 },
53
+ ],
54
+ });
56
55
 
57
56
  console.log({
58
57
  createTorpedo,
@@ -684,7 +683,7 @@ async function main() {
684
683
  { name: "LIMS_RUNNER", label: "Runner" },
685
684
  { name: "6_PIT", label: "6-Pit" },
686
685
  { name: "HOTMETAL_LEVEL", label: "Hot Metal Level" },
687
- { name: "HMH", label: "HMH"},
686
+ { name: "HMH", label: "HMH" },
688
687
  { name: "TORPEDO", label: "Torpedo" },
689
688
  { name: "TORPEDO_DUMPED", label: "Dumped" },
690
689
  { name: "TORPEDO_EMPTY", label: "Empty" },