@bslau/hmm_prisma_schema 1.3.3 → 1.4.1
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/.prettierignore +4 -0
- package/.prettierrc +3 -0
- package/package.json +5 -1
- package/prisma/dbClient.ts +1 -1
- package/prisma/migrations/20250523011817_notifications/migration.sql +92 -0
- package/prisma/migrations/20250526012646_hotmetal_mass_hot_metal_tldl_estimated_float/migration.sql +19 -0
- package/prisma/schema.prisma +63 -1
- package/prisma/seed.ts +702 -588
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bslau/hmm_prisma_schema",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"author": "CIPA Development Team",
|
|
6
6
|
"license": "ISC",
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
"prisma:create": "npx prisma migrate dev --create-only",
|
|
16
16
|
"prisma:deploy": "npx prisma migrate deploy",
|
|
17
17
|
"prisma:seed": "npx prisma db seed",
|
|
18
|
+
"prettier:check": "npx prettier --check prisma",
|
|
19
|
+
"prettier:write": "npx prettier --write prisma",
|
|
18
20
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
19
21
|
},
|
|
20
22
|
"types": "./index.d.ts",
|
|
@@ -22,6 +24,8 @@
|
|
|
22
24
|
"@prisma/client": "^6.2.1",
|
|
23
25
|
"@types/node": "^22.12.0",
|
|
24
26
|
"@types/underscore": "^1.13.0",
|
|
27
|
+
"prettier": "^3.5.3",
|
|
28
|
+
"prettier-plugin-prisma": "^5.0.0",
|
|
25
29
|
"prisma": "^6.2.1",
|
|
26
30
|
"ts-node": "^10.9.2",
|
|
27
31
|
"tsx": "^4.19.2",
|
package/prisma/dbClient.ts
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
BEGIN TRY
|
|
2
|
+
|
|
3
|
+
BEGIN TRAN;
|
|
4
|
+
|
|
5
|
+
-- CreateTable
|
|
6
|
+
CREATE TABLE [dbo].[Notification] (
|
|
7
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
8
|
+
[name] NVARCHAR(1000) NOT NULL,
|
|
9
|
+
[message] NVARCHAR(1000) NOT NULL,
|
|
10
|
+
[notificationSourceId] INT NOT NULL,
|
|
11
|
+
[torpedoId] INT NOT NULL,
|
|
12
|
+
[createdAt] DATETIME2 NOT NULL CONSTRAINT [Notification_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
|
|
13
|
+
[updatedAt] DATETIME2 NOT NULL,
|
|
14
|
+
CONSTRAINT [Notification_pkey] PRIMARY KEY CLUSTERED ([id])
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
-- CreateTable
|
|
18
|
+
CREATE TABLE [dbo].[NotificationCategory] (
|
|
19
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
20
|
+
[name] NVARCHAR(1000) NOT NULL,
|
|
21
|
+
[label] NVARCHAR(1000) NOT NULL,
|
|
22
|
+
CONSTRAINT [NotificationCategory_pkey] PRIMARY KEY CLUSTERED ([id]),
|
|
23
|
+
CONSTRAINT [NotificationCategory_name_key] UNIQUE NONCLUSTERED ([name])
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
-- CreateTable
|
|
27
|
+
CREATE TABLE [dbo].[NotificationDisplayMode] (
|
|
28
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
29
|
+
[displayModeId] INT NOT NULL,
|
|
30
|
+
[notificationId] INT NOT NULL,
|
|
31
|
+
CONSTRAINT [NotificationDisplayMode_pkey] PRIMARY KEY CLUSTERED ([id])
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
-- CreateTable
|
|
35
|
+
CREATE TABLE [dbo].[displayMode] (
|
|
36
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
37
|
+
[name] NVARCHAR(1000) NOT NULL,
|
|
38
|
+
[label] NVARCHAR(1000) NOT NULL,
|
|
39
|
+
[description] NVARCHAR(1000) NOT NULL,
|
|
40
|
+
CONSTRAINT [displayMode_pkey] PRIMARY KEY CLUSTERED ([id]),
|
|
41
|
+
CONSTRAINT [displayMode_name_key] UNIQUE NONCLUSTERED ([name])
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
-- CreateTable
|
|
45
|
+
CREATE TABLE [dbo].[NotificationSource] (
|
|
46
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
47
|
+
[name] NVARCHAR(1000) NOT NULL,
|
|
48
|
+
[label] NVARCHAR(1000) NOT NULL,
|
|
49
|
+
CONSTRAINT [NotificationSource_pkey] PRIMARY KEY CLUSTERED ([id]),
|
|
50
|
+
CONSTRAINT [NotificationSource_name_key] UNIQUE NONCLUSTERED ([name])
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
-- CreateTable
|
|
54
|
+
CREATE TABLE [dbo].[_NotificationToNotificationCategory] (
|
|
55
|
+
[A] INT NOT NULL,
|
|
56
|
+
[B] INT NOT NULL,
|
|
57
|
+
CONSTRAINT [_NotificationToNotificationCategory_AB_unique] UNIQUE NONCLUSTERED ([A],[B])
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
-- CreateIndex
|
|
61
|
+
CREATE NONCLUSTERED INDEX [_NotificationToNotificationCategory_B_index] ON [dbo].[_NotificationToNotificationCategory]([B]);
|
|
62
|
+
|
|
63
|
+
-- AddForeignKey
|
|
64
|
+
ALTER TABLE [dbo].[Notification] ADD CONSTRAINT [Notification_notificationSourceId_fkey] FOREIGN KEY ([notificationSourceId]) REFERENCES [dbo].[NotificationSource]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
|
65
|
+
|
|
66
|
+
-- AddForeignKey
|
|
67
|
+
ALTER TABLE [dbo].[Notification] ADD CONSTRAINT [Notification_torpedoId_fkey] FOREIGN KEY ([torpedoId]) REFERENCES [dbo].[Torpedo]([torpedoId]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
|
68
|
+
|
|
69
|
+
-- AddForeignKey
|
|
70
|
+
ALTER TABLE [dbo].[NotificationDisplayMode] ADD CONSTRAINT [NotificationDisplayMode_displayModeId_fkey] FOREIGN KEY ([displayModeId]) REFERENCES [dbo].[displayMode]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
|
71
|
+
|
|
72
|
+
-- AddForeignKey
|
|
73
|
+
ALTER TABLE [dbo].[NotificationDisplayMode] ADD CONSTRAINT [NotificationDisplayMode_notificationId_fkey] FOREIGN KEY ([notificationId]) REFERENCES [dbo].[Notification]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
|
74
|
+
|
|
75
|
+
-- AddForeignKey
|
|
76
|
+
ALTER TABLE [dbo].[_NotificationToNotificationCategory] ADD CONSTRAINT [_NotificationToNotificationCategory_A_fkey] FOREIGN KEY ([A]) REFERENCES [dbo].[Notification]([id]) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
77
|
+
|
|
78
|
+
-- AddForeignKey
|
|
79
|
+
ALTER TABLE [dbo].[_NotificationToNotificationCategory] ADD CONSTRAINT [_NotificationToNotificationCategory_B_fkey] FOREIGN KEY ([B]) REFERENCES [dbo].[NotificationCategory]([id]) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
80
|
+
|
|
81
|
+
COMMIT TRAN;
|
|
82
|
+
|
|
83
|
+
END TRY
|
|
84
|
+
BEGIN CATCH
|
|
85
|
+
|
|
86
|
+
IF @@TRANCOUNT > 0
|
|
87
|
+
BEGIN
|
|
88
|
+
ROLLBACK TRAN;
|
|
89
|
+
END;
|
|
90
|
+
THROW
|
|
91
|
+
|
|
92
|
+
END CATCH
|
package/prisma/migrations/20250526012646_hotmetal_mass_hot_metal_tldl_estimated_float/migration.sql
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
BEGIN TRY
|
|
2
|
+
|
|
3
|
+
BEGIN TRAN;
|
|
4
|
+
|
|
5
|
+
-- AlterTable
|
|
6
|
+
ALTER TABLE [dbo].[HotMetal] ALTER COLUMN [massHotMetalTldlEstimated] FLOAT(53) NULL;
|
|
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
|
package/prisma/schema.prisma
CHANGED
|
@@ -192,7 +192,7 @@ model HotMetal {
|
|
|
192
192
|
dpLevelTldlManual Int?
|
|
193
193
|
capacity Int?
|
|
194
194
|
massHotMetalResidueTldl Int?
|
|
195
|
-
massHotMetalTldlEstimated
|
|
195
|
+
massHotMetalTldlEstimated Float?
|
|
196
196
|
massActual Int?
|
|
197
197
|
pot Pot? @relation(fields: [potId], references: [id])
|
|
198
198
|
potId Int?
|
|
@@ -374,6 +374,7 @@ model Torpedo {
|
|
|
374
374
|
campaignsSurvey CampaignSurvey[]
|
|
375
375
|
torpedoCycle TorpedoCycle[]
|
|
376
376
|
torpedoTrips TorpedoTrip[]
|
|
377
|
+
notifications Notification[]
|
|
377
378
|
torpedoState TorpedoState? @relation(fields: [torpedoStateId], references: [id])
|
|
378
379
|
torpedoStateId Int?
|
|
379
380
|
createdAt DateTime @default(now())
|
|
@@ -464,3 +465,64 @@ model TorpedoTrip {
|
|
|
464
465
|
startTime DateTime @default(now()) @db.DateTimeOffset
|
|
465
466
|
endTime DateTime? @db.DateTimeOffset
|
|
466
467
|
}
|
|
468
|
+
|
|
469
|
+
/// **HMM NOTIFICATIONS**
|
|
470
|
+
///
|
|
471
|
+
/// Data structure to handle all notifications for HMM
|
|
472
|
+
model Notification {
|
|
473
|
+
id Int @id @default(autoincrement())
|
|
474
|
+
name String
|
|
475
|
+
message String
|
|
476
|
+
notificationCategories NotificationCategory[]
|
|
477
|
+
notificationDisplayModes NotificationDisplayMode[]
|
|
478
|
+
notificationSource NotificationSource @relation(fields: [notificationSourceId], references: [id], onDelete: NoAction, onUpdate: Cascade)
|
|
479
|
+
notificationSourceId Int
|
|
480
|
+
torpedo Torpedo? @relation(fields: [torpedoId], references: [torpedoId], onDelete: NoAction, onUpdate: Cascade)
|
|
481
|
+
torpedoId Int
|
|
482
|
+
createdAt DateTime @default(now())
|
|
483
|
+
updatedAt DateTime @updatedAt
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/// **HMM Notification Category**
|
|
487
|
+
///
|
|
488
|
+
/// These Categories define how notifications are grouped for filtering purposes in HMM.
|
|
489
|
+
/// Also used to define the colour and other attributes for the notification as displayed on screen
|
|
490
|
+
model NotificationCategory {
|
|
491
|
+
id Int @id @default(autoincrement())
|
|
492
|
+
name String @unique
|
|
493
|
+
label String
|
|
494
|
+
notifications Notification[]
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/// ***HMM Display Modes for Notifications***
|
|
498
|
+
///
|
|
499
|
+
/// These display modes define how these notifications are displayed to the User
|
|
500
|
+
model NotificationDisplayMode {
|
|
501
|
+
id Int @id @default(autoincrement())
|
|
502
|
+
displayModeId Int
|
|
503
|
+
displayMode displayMode @relation(fields: [displayModeId], references: [id])
|
|
504
|
+
notification Notification @relation(fields: [notificationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
|
|
505
|
+
notificationId Int
|
|
506
|
+
// status Boolean @default(false) NOTES: Probably add something like this later to check for example if a notification has been acknowledged by the user
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/// ** HMM Display Mode Definitions **
|
|
510
|
+
///
|
|
511
|
+
/// These are the Defined Display Modes available to the HMM Application
|
|
512
|
+
model displayMode {
|
|
513
|
+
id Int @id @default(autoincrement())
|
|
514
|
+
name String @unique
|
|
515
|
+
label String
|
|
516
|
+
description String
|
|
517
|
+
notificationDisplayModes NotificationDisplayMode[]
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/// ** HMM Notification Source **
|
|
521
|
+
///
|
|
522
|
+
/// A definition table for where each notification originated from
|
|
523
|
+
model NotificationSource {
|
|
524
|
+
id Int @id @default(autoincrement())
|
|
525
|
+
name String @unique
|
|
526
|
+
label String
|
|
527
|
+
notifications Notification[]
|
|
528
|
+
}
|