@bslau/hmm_prisma_schema 1.4.1 → 1.5.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/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.1",
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,24 +497,24 @@ 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())
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
500
+ model NotificationDisplay {
501
+ id Int @id @default(autoincrement())
502
+ displayModeId Int
503
+ notificationDisplayMode NotificationDisplayMode @relation(fields: [displayModeId], references: [id])
504
+ notification Notification @relation(fields: [notificationId], references: [id], onDelete: NoAction, onUpdate: Cascade)
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
  }
508
508
 
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
515
- label String
516
- description String
517
- notificationDisplayModes NotificationDisplayMode[]
512
+ model NotificationDisplayMode {
513
+ id Int @id @default(autoincrement())
514
+ name String @unique
515
+ label String
516
+ description String
517
+ notificationDisplays NotificationDisplay[]
518
518
  }
519
519
 
520
520
  /// ** HMM Notification Source **
package/prisma/seed.ts CHANGED
@@ -2,6 +2,63 @@ import _ from "underscore";
2
2
  import prisma from "./dbClient";
3
3
 
4
4
  async function main() {
5
+ // SEED: Torpedos
6
+ if ((await prisma.torpedo.count()) > 0) {
7
+ console.log("SEED: Torpedo - skipped.");
8
+ } else {
9
+ console.log("SEED: Torpedo - generating...");
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
+ });
56
+
57
+ console.log({
58
+ createTorpedo,
59
+ });
60
+ }
61
+
5
62
  // SEED: Station
6
63
  if ((await prisma.station.count()) > 0) {
7
64
  console.log("SEED: Station - skipped.");
@@ -528,7 +585,7 @@ async function main() {
528
585
  for (let i: number = 0; i < remainingTorpedoes.length; i++) {
529
586
  const randomLocation = await prisma.torpedoLocation.create({
530
587
  data: {
531
- stationId: 1,
588
+ stationId: stationList[0].id,
532
589
  position: 2 + i,
533
590
  torpedoId: remainingTorpedoes[i].torpedoId,
534
591
  locationId: stationList[0].locations[0].id,
@@ -649,12 +706,12 @@ async function main() {
649
706
  }
650
707
 
651
708
  // SEED: NotificationDisplay
652
- if ((await prisma.displayMode.count()) > 0) {
653
- console.log("SEED: DisplayMode - skipped.");
709
+ if ((await prisma.notificationDisplayMode.count()) > 0) {
710
+ console.log("SEED: NotificationDisplayMode - skipped.");
654
711
  } else {
655
- console.log("SEED: DisplayMode - generating...");
712
+ console.log("SEED: NotificationDisplayMode - generating...");
656
713
 
657
- const createDisplayMode = await prisma.displayMode.createMany({
714
+ const createDisplayMode = await prisma.notificationDisplayMode.createMany({
658
715
  data: [
659
716
  {
660
717
  name: "BELL",