@bslau/hmm_prisma_schema 1.4.1 → 1.5.0

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.4.1",
3
+ "version": "1.5.0",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -15,6 +15,7 @@
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
+ "prisma:format": "npx prisma format",
18
19
  "prettier:check": "npx prettier --check prisma",
19
20
  "prettier:write": "npx prettier --write prisma",
20
21
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,64 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `displayModeId` on the `NotificationDisplayMode` table. All the data in the column will be lost.
5
+ - You are about to drop the column `notificationId` on the `NotificationDisplayMode` table. All the data in the column will be lost.
6
+ - You are about to drop the `displayMode` table. If the table is not empty, all the data it contains will be lost.
7
+ - A unique constraint covering the columns `[name]` on the table `NotificationDisplayMode` will be added. If there are existing duplicate values, this will fail.
8
+ - Added the required column `description` to the `NotificationDisplayMode` table without a default value. This is not possible if the table is not empty.
9
+ - Added the required column `label` to the `NotificationDisplayMode` table without a default value. This is not possible if the table is not empty.
10
+ - Added the required column `name` to the `NotificationDisplayMode` table without a default value. This is not possible if the table is not empty.
11
+
12
+ */
13
+ BEGIN TRY
14
+
15
+ BEGIN TRAN;
16
+
17
+ -- DropForeignKey
18
+ ALTER TABLE [dbo].[NotificationDisplayMode] DROP CONSTRAINT [NotificationDisplayMode_displayModeId_fkey];
19
+
20
+ -- DropForeignKey
21
+ ALTER TABLE [dbo].[NotificationDisplayMode] DROP CONSTRAINT [NotificationDisplayMode_notificationId_fkey];
22
+
23
+ -- AlterTable
24
+ ALTER TABLE [dbo].[Notification] ALTER COLUMN [torpedoId] INT NULL;
25
+
26
+ -- AlterTable
27
+ ALTER TABLE [dbo].[NotificationDisplayMode] DROP COLUMN [displayModeId],
28
+ [notificationId];
29
+ ALTER TABLE [dbo].[NotificationDisplayMode] ADD [description] NVARCHAR(1000) NOT NULL,
30
+ [label] NVARCHAR(1000) NOT NULL,
31
+ [name] NVARCHAR(1000) NOT NULL;
32
+
33
+ -- DropTable
34
+ DROP TABLE [dbo].[displayMode];
35
+
36
+ -- CreateTable
37
+ CREATE TABLE [dbo].[NotificationDisplay] (
38
+ [id] INT NOT NULL IDENTITY(1,1),
39
+ [displayModeId] INT NOT NULL,
40
+ [notificationId] INT NOT NULL,
41
+ CONSTRAINT [NotificationDisplay_pkey] PRIMARY KEY CLUSTERED ([id])
42
+ );
43
+
44
+ -- CreateIndex
45
+ ALTER TABLE [dbo].[NotificationDisplayMode] ADD CONSTRAINT [NotificationDisplayMode_name_key] UNIQUE NONCLUSTERED ([name]);
46
+
47
+ -- AddForeignKey
48
+ ALTER TABLE [dbo].[NotificationDisplay] ADD CONSTRAINT [NotificationDisplay_displayModeId_fkey] FOREIGN KEY ([displayModeId]) REFERENCES [dbo].[NotificationDisplayMode]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
49
+
50
+ -- AddForeignKey
51
+ ALTER TABLE [dbo].[NotificationDisplay] ADD CONSTRAINT [NotificationDisplay_notificationId_fkey] FOREIGN KEY ([notificationId]) REFERENCES [dbo].[Notification]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
52
+
53
+ COMMIT TRAN;
54
+
55
+ END TRY
56
+ BEGIN CATCH
57
+
58
+ IF @@TRANCOUNT > 0
59
+ BEGIN
60
+ ROLLBACK TRAN;
61
+ END;
62
+ THROW
63
+
64
+ END CATCH
@@ -470,17 +470,17 @@ model TorpedoTrip {
470
470
  ///
471
471
  /// Data structure to handle all notifications for HMM
472
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
473
+ id Int @id @default(autoincrement())
474
+ name String
475
+ message String
476
+ notificationCategories NotificationCategory[]
477
+ notificationDisplays NotificationDisplay[]
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
484
  }
485
485
 
486
486
  /// **HMM Notification Category**
@@ -497,11 +497,11 @@ model NotificationCategory {
497
497
  /// ***HMM Display Modes for Notifications***
498
498
  ///
499
499
  /// These display modes define how these notifications are displayed to the User
500
- model NotificationDisplayMode {
501
- id Int @id @default(autoincrement())
500
+ model NotificationDisplay {
501
+ id Int @id @default(autoincrement())
502
502
  displayModeId Int
503
- displayMode displayMode @relation(fields: [displayModeId], references: [id])
504
- notification Notification @relation(fields: [notificationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
503
+ displayMode NotificationDisplayMode @relation(fields: [displayModeId], references: [id])
504
+ notification Notification @relation(fields: [notificationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
505
505
  notificationId Int
506
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
507
  }
@@ -509,12 +509,12 @@ model NotificationDisplayMode {
509
509
  /// ** HMM Display Mode Definitions **
510
510
  ///
511
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
512
+ model NotificationDisplayMode {
513
+ id Int @id @default(autoincrement())
514
+ name String @unique
515
515
  label String
516
516
  description String
517
- notificationDisplayModes NotificationDisplayMode[]
517
+ notificationDisplayModes NotificationDisplay[]
518
518
  }
519
519
 
520
520
  /// ** HMM Notification Source **
package/prisma/seed.ts CHANGED
@@ -649,12 +649,12 @@ async function main() {
649
649
  }
650
650
 
651
651
  // SEED: NotificationDisplay
652
- if ((await prisma.displayMode.count()) > 0) {
652
+ if ((await prisma.notificationDisplayMode.count()) > 0) {
653
653
  console.log("SEED: DisplayMode - skipped.");
654
654
  } else {
655
655
  console.log("SEED: DisplayMode - generating...");
656
656
 
657
- const createDisplayMode = await prisma.displayMode.createMany({
657
+ const createDisplayMode = await prisma.notificationDisplayMode.createMany({
658
658
  data: [
659
659
  {
660
660
  name: "BELL",