@bslau/hmm_prisma_schema 1.1.22 → 1.2.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/README.md CHANGED
@@ -1,31 +1,44 @@
1
- # Introduction
2
- TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
1
+ # Editing Prisma Schema
3
2
 
4
- # Getting Started
5
- TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
6
- 1. Installation process
7
- 2. Software dependencies
8
- 3. Latest releases
9
- 4. API references
3
+ The general workflow will follow these steps:
10
4
 
11
- # Build and Test
12
- TODO: Describe and show how to build your code and run the tests.
5
+ - Create and checkout a new working branch.
6
+ - Edit `schema.prisma` as needed.
7
+ - Run automated formatting: `npx prisma format`
8
+ - Prepare database changes (as needed):
9
+ - create (preview) migration: `npm prisma:create` or;
10
+ - create and apply migration: `npm prisma:apply`
11
+ - Update *minor* version number in `package.json`
12
+ `"version": "[MAJOR].[MINOR].[PATCH]"`
13
+ - Create and test new seeding function(s) if required - being cautious to avoid creating **duplicate** records on repeated runs.
14
+ - Raise PR for merging back into main branch.
13
15
 
14
- # Edit prisma schema
15
- TODO: Explain how other users and developers can edit prisma schema.
16
- >create a branch
16
+ The changes should be ready for review, merging, and publishing now.
17
17
 
18
- >edit schema.prisma
18
+ # Deploying Prisma Schema
19
19
 
20
- >npx prisma format
20
+ Completing the PR (merging into main) will automatically trigger the build and release pipelines that will publish the new version of the package to the remote npm repository.
21
21
 
22
- >npx prisma migrate dev --name new schema
22
+ The latest version can then be installed in the application implementing the schema:
23
23
 
24
- >update version in package.json
24
+ `npm install @bslau/hmm_prisma_schema`
25
25
 
26
- >raise PR for merging to main branch
26
+ *NOTE* that doing this on the BlueScope network will typically **fail**. Installing this package involves generating a fresh Prisma client file - this is the part that seems to stall/fail because it's ignorant of the system proxy settings. The workaround is to use a hotspot internet connection without any proxy settings instead.
27
27
 
28
- If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
29
- - [ASP.NET Core](https://github.com/aspnet/Home)
30
- - [Visual Studio Code](https://github.com/Microsoft/vscode)
31
- - [Chakra Core](https://github.com/Microsoft/ChakraCore)
28
+ # Manual Deployment for Test Environment
29
+
30
+ Current implementations of this package **don't** automate migration and seeding steps after release to the Test environment. This will result in schema mismatch between the Prisma package and the Test database when updates are released.
31
+
32
+ The workaround is to manually execute these steps after release. This example describes the process for the *GraphQL Apollo* server, but would also work for the *Event Processing* service (albeit in a different directory):
33
+
34
+ - RDP into the host server: `ITAVWEB91`
35
+
36
+ - Open a bash terminal and navigate to the installed package:
37
+
38
+ `cd /c/inetpub/wwwroot/hmm/graphql_server/node_modules/@bslau/hmm_prisma_schema`
39
+
40
+ - Apply any pending migrations: `npm run prisma:deploy`
41
+
42
+ - Run the seed function to create data: `npm run prisma:seed`
43
+
44
+ At this point, assuming no errors in deploying or seeding, the Test database schema should be synchronised with Prisma now.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bslau/hmm_prisma_schema",
3
- "version": "1.1.22",
3
+ "version": "1.2.0",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -14,6 +14,7 @@
14
14
  "prisma:apply": "npx prisma migrate dev",
15
15
  "prisma:create": "npx prisma migrate dev --create-only",
16
16
  "prisma:deploy": "npx prisma migrate deploy",
17
+ "prisma:seed": "npx prisma db seed",
17
18
  "test": "echo \"Error: no test specified\" && exit 1"
18
19
  },
19
20
  "types": "./index.d.ts",
@@ -0,0 +1,20 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- AlterTable
6
+ ALTER TABLE [dbo].[Torpedo] ADD [capacityDynamic] FLOAT(53),
7
+ [capacityNominal] FLOAT(53) NOT NULL CONSTRAINT [Torpedo_capacityNominal_df] DEFAULT 200;
8
+
9
+ COMMIT TRAN;
10
+
11
+ END TRY
12
+ BEGIN CATCH
13
+
14
+ IF @@TRANCOUNT > 0
15
+ BEGIN
16
+ ROLLBACK TRAN;
17
+ END;
18
+ THROW
19
+
20
+ END CATCH
@@ -0,0 +1,26 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `capacityDynamic` on the `Torpedo` table. All the data in the column will be lost.
5
+
6
+ */
7
+ BEGIN TRY
8
+
9
+ BEGIN TRAN;
10
+
11
+ -- AlterTable
12
+ ALTER TABLE [dbo].[Torpedo] DROP COLUMN [capacityDynamic];
13
+ ALTER TABLE [dbo].[Torpedo] ADD [capacityAverage] FLOAT(53);
14
+
15
+ COMMIT TRAN;
16
+
17
+ END TRY
18
+ BEGIN CATCH
19
+
20
+ IF @@TRANCOUNT > 0
21
+ BEGIN
22
+ ROLLBACK TRAN;
23
+ END;
24
+ THROW
25
+
26
+ END CATCH
@@ -325,8 +325,8 @@ model Torpedo {
325
325
  sixPitRestrictionEndTime DateTime? @db.DateTimeOffset
326
326
  status Int @default(2)
327
327
  // sixPitStart DateTime?
328
- // capacityDynamic Float?
329
- // capacityNominal Float?
328
+ capacityAverage Float?
329
+ capacityNominal Float @default(200)
330
330
  // comments String?
331
331
  // emptyWeight Float?
332
332
  // gasStart DateTime?