@bslau/hmm_prisma_schema 1.5.1 → 1.5.3

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.1",
3
+ "version": "1.5.3",
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,23 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- AlterTable
6
+ ALTER TABLE [dbo].[EventTorpedoMovement] DROP CONSTRAINT [EventTorpedoMovement_torpedoStateId_df];
7
+ ALTER TABLE [dbo].[EventTorpedoMovement] ALTER COLUMN [torpedoStateId] INT NULL;
8
+
9
+ -- AddForeignKey
10
+ ALTER TABLE [dbo].[EventTorpedoMovement] ADD CONSTRAINT [EventTorpedoMovement_torpedoStateId_fkey] FOREIGN KEY ([torpedoStateId]) REFERENCES [dbo].[TorpedoState]([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;
11
+
12
+ COMMIT TRAN;
13
+
14
+ END TRY
15
+ BEGIN CATCH
16
+
17
+ IF @@TRANCOUNT > 0
18
+ BEGIN
19
+ ROLLBACK TRAN;
20
+ END;
21
+ THROW
22
+
23
+ END CATCH
@@ -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
@@ -101,7 +101,6 @@ model EventTorpedoMovement {
101
101
  id Int @id @default(autoincrement())
102
102
  torpedoId Int
103
103
  torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
104
- torpedoStateId Int @default(0)
105
104
  eventTime DateTime @db.DateTimeOffset
106
105
  originStation Station @relation(name: "originStation-movement", fields: [originStationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
107
106
  originStationId Int
@@ -118,6 +117,8 @@ model EventTorpedoMovement {
118
117
  torpedoCycleId Int?
119
118
  torpedoTrip TorpedoTrip? @relation(fields: [torpedoTripId], references: [id])
120
119
  torpedoTripId Int?
120
+ torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id], onDelete: NoAction, onUpdate: NoAction)
121
+ torpedoStateId Int?
121
122
  createdAt DateTime @default(now())
122
123
  updatedAt DateTime @updatedAt
123
124
  }
@@ -139,6 +140,18 @@ model EventTorpedoCapacity {
139
140
  updatedAt DateTime @updatedAt
140
141
  }
141
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
+ maintenanceDate DateTime @db.DateTimeOffset
149
+ torpedoId Int
150
+ torpedo Torpedo @relation(fields: [torpedoId], references: [torpedoId])
151
+ createdAt DateTime @default(now())
152
+ updatedAt DateTime @updatedAt
153
+ }
154
+
142
155
  /// **EVENT TRACKER**
143
156
  ///
144
157
  /// Represents a generic system _Event_, which maps to its model instance.
@@ -344,23 +357,23 @@ model Station {
344
357
  /// system cares about how efficiently that's happening, and how much total
345
358
  /// work they do.
346
359
  model Torpedo {
347
- id Int @id @default(autoincrement())
348
- torpedoId Int @unique(sort: Desc)
360
+ id Int @id @default(autoincrement())
361
+ torpedoId Int @unique(sort: Desc)
349
362
  name String?
350
363
  description String?
351
364
  futureLocation String?
352
- addAlPucksFlag Boolean @default(false)
353
- heatUpFlag Boolean @default(false)
354
- heatUpStartTime DateTime? @db.DateTimeOffset
355
- onGasFlag Boolean @default(false)
356
- onGasEndDate DateTime? @db.DateTimeOffset
357
- hmhSixPitRestrictionFlag Boolean @default(false)
358
- sixPitRestrictionFlag Boolean @default(false)
359
- sixPitRestrictionEndTime DateTime? @db.DateTimeOffset
360
- status Int @default(2)
365
+ addAlPucksFlag Boolean @default(false)
366
+ heatUpFlag Boolean @default(false)
367
+ heatUpStartTime DateTime? @db.DateTimeOffset
368
+ onGasFlag Boolean @default(false)
369
+ onGasEndDate DateTime? @db.DateTimeOffset
370
+ hmhSixPitRestrictionFlag Boolean @default(false)
371
+ sixPitRestrictionFlag Boolean @default(false)
372
+ sixPitRestrictionEndTime DateTime? @db.DateTimeOffset
373
+ status Int @default(2)
361
374
  // sixPitStart DateTime?
362
375
  capacityAverage Float?
363
- capacityNominal Float @default(200)
376
+ capacityNominal Float @default(200)
364
377
  // comments String?
365
378
  // emptyWeight Float?
366
379
  // gasStart DateTime?
@@ -370,15 +383,16 @@ model Torpedo {
370
383
  hmhComments HMHComment[]
371
384
  eventsTorpedoMovement EventTorpedoMovement[]
372
385
  eventTorpedoCapacity EventTorpedoCapacity[]
386
+ eventTorpedoMaintenance EventTorpedoMaintenance[]
373
387
  campaignsRebricking CampaignRebricking[]
374
388
  campaignsSurvey CampaignSurvey[]
375
389
  torpedoCycle TorpedoCycle[]
376
390
  torpedoTrips TorpedoTrip[]
377
391
  notifications Notification[]
378
- torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id])
392
+ torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id])
379
393
  torpedoStateId Int?
380
- createdAt DateTime @default(now())
381
- updatedAt DateTime @updatedAt
394
+ createdAt DateTime @default(now())
395
+ updatedAt DateTime @updatedAt
382
396
  }
383
397
 
384
398
  /// **TORPEDO COMMENT**
@@ -436,11 +450,12 @@ model TorpedoLocation {
436
450
  ///
437
451
  /// Describes a valid operational _State_ that a _Torpedo_ can be assigned.
438
452
  model TorpedoState {
439
- id Int @id @default(autoincrement())
440
- name String @unique
441
- label String
442
- description String
443
- torpedoes Torpedo[]
453
+ id Int @id @default(autoincrement())
454
+ name String @unique
455
+ label String
456
+ description String
457
+ torpedoes Torpedo[]
458
+ eventsTorpedoMovement EventTorpedoMovement[]
444
459
  }
445
460
 
446
461
  /// **TORPEDO TRIP (ON LINING)**
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" },