@bslau/hmm_prisma_schema 1.8.1 → 1.9.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
@@ -4,7 +4,7 @@ The general workflow will follow these steps:
4
4
 
5
5
  - Create and checkout a new working branch.
6
6
  - Edit `schema.prisma` as needed.
7
- - Run automated formatting: `npx prisma format`
7
+ - Run automated formatting: `npm run prisma:format`
8
8
  - Prepare database changes (as needed):
9
9
  - create (preview) migration: `npm run prisma:create` or;
10
10
  - create and apply migration: `npm run prisma:apply`
@@ -35,7 +35,7 @@ The workaround is to manually execute these steps after release. This example de
35
35
 
36
36
  - Open a bash terminal and navigate to the installed package:
37
37
 
38
- `cd /c/inetpub/wwwroot/hmm/graphql_server/node_modules/@bslau/hmm_prisma_schema`
38
+ `C:\inetpub\wwwroot\hmm\graphql_server\node_modules\@bslau\hmm_prisma_schema`
39
39
 
40
40
  - Apply any pending migrations: `npm run prisma:deploy`
41
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bslau/hmm_prisma_schema",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -0,0 +1,19 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- AlterTable
6
+ ALTER TABLE [dbo].[HotMetal] ADD [pourStatus] INT NOT NULL CONSTRAINT [HotMetal_pourStatus_df] DEFAULT 0;
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
@@ -204,6 +204,7 @@ model HotMetal {
204
204
  containsPunchOut Boolean @default(false)
205
205
  alPucksAdded Boolean @default(false)
206
206
  integrationStage Int @default(0)
207
+ pourStatus Int @default(0)
207
208
  createdAt DateTime @default(now())
208
209
  updatedAt DateTime @updatedAt
209
210
 
package/prisma/seed.ts CHANGED
@@ -1,8 +1,40 @@
1
1
  import _ from "underscore";
2
2
  import prisma from "./dbClient";
3
3
 
4
+ // SEED: Function to add Locations to Stations
5
+ async function addLocationsToStation(
6
+ stationValue: string,
7
+ locations: { value: string; name: string }[]
8
+ ) {
9
+ for (const loc of locations) {
10
+ // Ensure the location exists and has the correct name
11
+ await prisma.location.upsert({
12
+ where: { value: loc.value },
13
+ update: {
14
+ name: loc.name, // Updates name if changed
15
+ },
16
+ create: {
17
+ value: loc.value,
18
+ name: loc.name,
19
+ },
20
+ });
21
+
22
+ // Connect the location to the specified station
23
+ await prisma.station.update({
24
+ where: { value: stationValue },
25
+ data: {
26
+ locations: {
27
+ connect: { value: loc.value },
28
+ },
29
+ },
30
+ });
31
+
32
+ console.log(`Location ${loc.value} connected to station ${stationValue}`);
33
+ }
34
+ }
35
+
4
36
  async function main() {
5
- // SEED: Torpedos
37
+ // SEED: Torpedoes
6
38
  if ((await prisma.torpedo.count()) > 0) {
7
39
  console.log("SEED: Torpedo - skipped.");
8
40
  } else {
@@ -64,460 +96,123 @@ async function main() {
64
96
  } else {
65
97
  console.log("SEED: Station - generating...");
66
98
 
99
+ // Holding
67
100
  const createHolding = await prisma.station.create({
68
101
  data: {
69
102
  value: "HOLDING",
70
103
  name: "Holding",
71
- locations: {
72
- connectOrCreate: [
73
- {
74
- where: {
75
- value: "WPR",
76
- },
77
- create: {
78
- value: "WPR",
79
- name: "Woodpecker Repair Lines",
80
- },
81
- },
82
- {
83
- where: {
84
- value: "5OL",
85
- },
86
- create: {
87
- value: "5OL",
88
- name: "5 Outside Loop",
89
- },
90
- },
91
- {
92
- where: {
93
- value: "5BF",
94
- },
95
- create: {
96
- value: "5BF",
97
- name: "5 Blast Furnace",
98
- },
99
- },
100
- {
101
- where: {
102
- value: "OPM",
103
- },
104
- create: {
105
- value: "OPM",
106
- name: "Old Plug Mill",
107
- },
108
- },
109
- {
110
- where: {
111
- value: "XOVR",
112
- },
113
- create: {
114
- value: "XOVR",
115
- name: "Short Cross Over",
116
- },
117
- },
118
- {
119
- where: {
120
- value: "5ML",
121
- },
122
- create: {
123
- value: "5ML",
124
- name: "5 BF Middle Loop",
125
- },
126
- },
127
- {
128
- where: {
129
- value: "6BF",
130
- },
131
- create: {
132
- value: "6BF",
133
- name: "6 Blast Furnace",
134
- },
135
- },
136
- {
137
- where: {
138
- value: "DSML",
139
- },
140
- create: {
141
- value: "DSML",
142
- name: "Desulph Main Line",
143
- },
144
- },
145
- ],
146
- },
147
104
  },
148
105
  });
106
+
107
+ // 5BFE
149
108
  const create5BFE = await prisma.station.create({
150
109
  data: {
151
110
  value: "5BFE",
152
111
  name: "5 Blast Furnace - East",
153
- locations: {
154
- connectOrCreate: [
155
- {
156
- where: {
157
- value: "5BFE",
158
- },
159
- create: {
160
- value: "5BFE",
161
- name: "5 Blast Furnace - East",
162
- },
163
- },
164
- ],
165
- },
166
112
  },
167
113
  });
114
+
115
+ // 5BFN
168
116
  const create5BFN = await prisma.station.create({
169
117
  data: {
170
118
  value: "5BFN",
171
119
  name: "5 Blast Furnace - North",
172
- locations: {
173
- connectOrCreate: [
174
- {
175
- where: {
176
- value: "5BFN",
177
- },
178
- create: {
179
- value: "5BFN",
180
- name: "5 Blast Furnace - North",
181
- },
182
- },
183
- ],
184
- },
185
120
  },
186
121
  });
122
+
123
+ // 5BFW
187
124
  const create5BFW = await prisma.station.create({
188
125
  data: {
189
126
  value: "5BFW",
190
127
  name: "5 Blast Furnace - West",
191
- locations: {
192
- connectOrCreate: [
193
- {
194
- where: {
195
- value: "5BFW",
196
- },
197
- create: {
198
- value: "5BFW",
199
- name: "5 Blast Furnace - West",
200
- },
201
- },
202
- ],
203
- },
204
128
  },
205
129
  });
130
+
131
+ // Desulph 1
206
132
  const createDES1 = await prisma.station.create({
207
133
  data: {
208
134
  value: "DES1",
209
135
  name: "Desulphurisation 1",
210
- locations: {
211
- connectOrCreate: [
212
- {
213
- where: {
214
- value: "DES1",
215
- },
216
- create: {
217
- value: "DES1",
218
- name: "Desulphurisation 1",
219
- },
220
- },
221
- ],
222
- },
223
136
  },
224
137
  });
138
+
139
+ // Desulph 2
225
140
  const createDES2 = await prisma.station.create({
226
141
  data: {
227
142
  value: "DES2",
228
143
  name: "Desulphurisation 2",
229
- locations: {
230
- connectOrCreate: [
231
- {
232
- where: {
233
- value: "DES2",
234
- },
235
- create: {
236
- value: "DES2",
237
- name: "Desulphurisation 2",
238
- },
239
- },
240
- ],
241
- },
242
144
  },
243
145
  });
146
+
147
+ // 6PIT
244
148
  const create6PIT = await prisma.station.create({
245
149
  data: {
246
150
  value: "6PIT",
247
151
  name: "6 Pit",
248
- locations: {
249
- connectOrCreate: [
250
- {
251
- where: {
252
- value: "6PIT",
253
- },
254
- create: {
255
- value: "6PIT",
256
- name: "6 Pit",
257
- },
258
- },
259
- ],
260
- },
261
152
  },
262
153
  });
154
+
155
+ // WB1
263
156
  const createWB1 = await prisma.station.create({
264
157
  data: {
265
158
  value: "WB1",
266
159
  name: "Weighbridge 1",
267
- locations: {
268
- connectOrCreate: [
269
- {
270
- where: {
271
- value: "WB1",
272
- },
273
- create: {
274
- value: "WB1",
275
- name: "Weighbridge 1",
276
- },
277
- },
278
- ],
279
- },
280
160
  },
281
161
  });
162
+
163
+ // WB2
282
164
  const createWB2 = await prisma.station.create({
283
165
  data: {
284
166
  value: "WB2",
285
167
  name: "Weighbridge 2",
286
- locations: {
287
- connectOrCreate: [
288
- {
289
- where: {
290
- value: "WB2",
291
- },
292
- create: {
293
- value: "WB2",
294
- name: "Weighbridge 2",
295
- },
296
- },
297
- ],
298
- },
299
168
  },
300
169
  });
170
+
171
+ // 21 Dump
301
172
  const create21D = await prisma.station.create({
302
173
  data: {
303
174
  value: "21D",
304
175
  name: "Dump",
305
- locations: {
306
- connectOrCreate: [
307
- {
308
- where: {
309
- value: "21D",
310
- },
311
- create: {
312
- value: "21D",
313
- name: "Dump",
314
- },
315
- },
316
- ],
317
- },
318
176
  },
319
177
  });
178
+
179
+ // WB1 Holding
320
180
  const createWB1H = await prisma.station.create({
321
181
  data: {
322
182
  value: "WB1H",
323
183
  name: "Weighbridge 1 - Holding",
324
- locations: {
325
- connectOrCreate: [
326
- {
327
- where: {
328
- value: "WB1H",
329
- },
330
- create: {
331
- value: "WB1H",
332
- name: "Weighbridge 1 - Holding",
333
- },
334
- },
335
- ],
336
- },
337
184
  },
338
185
  });
186
+
187
+ // WB2 Holding
339
188
  const createWB2H = await prisma.station.create({
340
189
  data: {
341
190
  value: "WB2H",
342
191
  name: "Weighbridge 2 - Holding",
343
- locations: {
344
- connectOrCreate: [
345
- {
346
- where: {
347
- value: "WB2H",
348
- },
349
- create: {
350
- value: "WB2H",
351
- name: "Weighbridge 2 - Holding",
352
- },
353
- },
354
- ],
355
- },
356
192
  },
357
193
  });
194
+
195
+ // On Gas
358
196
  const createGAS = await prisma.station.create({
359
197
  data: {
360
198
  value: "GAS",
361
199
  name: "On Gas",
362
- locations: {
363
- connectOrCreate: [
364
- {
365
- where: {
366
- value: "GASL",
367
- },
368
- create: {
369
- value: "GASL",
370
- name: "Gasline",
371
- },
372
- },
373
- {
374
- where: {
375
- value: "COOL",
376
- },
377
- create: {
378
- value: "COOL",
379
- name: "Cooling Station",
380
- },
381
- },
382
- {
383
- where: {
384
- value: "5BFHL",
385
- },
386
- create: {
387
- value: "5BFHL",
388
- name: "No.5 Blast Furnace Heating line",
389
- },
390
- },
391
- ],
392
- },
393
200
  },
394
201
  });
202
+
203
+ // OOS
395
204
  const createOOS = await prisma.station.create({
396
205
  data: {
397
206
  value: "OOS",
398
207
  name: "Out Of Service",
399
- locations: {
400
- connectOrCreate: [
401
- {
402
- where: {
403
- value: "GASL",
404
- },
405
- create: {
406
- value: "GASL",
407
- name: "Gasline",
408
- },
409
- },
410
- {
411
- where: {
412
- value: "COOL",
413
- },
414
- create: {
415
- value: "COOL",
416
- name: "Cooling Station",
417
- },
418
- },
419
- {
420
- where: {
421
- value: "5BFHL",
422
- },
423
- create: {
424
- value: "5BFHL",
425
- name: "No.5 Blast Furnace Heating line",
426
- },
427
- },
428
- {
429
- where: {
430
- value: "5FDRY",
431
- },
432
- create: {
433
- value: "5FDRY",
434
- name: "No.5 position Foundry",
435
- },
436
- },
437
- {
438
- where: {
439
- value: "GUNR",
440
- },
441
- create: {
442
- value: "GUNR",
443
- name: "Gunning Road",
444
- },
445
- },
446
- {
447
- where: {
448
- value: "AWNR",
449
- },
450
- create: {
451
- value: "AWNR",
452
- name: "Awning Road",
453
- },
454
- },
455
- {
456
- where: {
457
- value: "REBS",
458
- },
459
- create: {
460
- value: "REBS",
461
- name: "Rebrick shed",
462
- },
463
- },
464
- {
465
- where: {
466
- value: "LRS1",
467
- },
468
- create: {
469
- value: "LRS1",
470
- name: "Ladle Repair shop road 1",
471
- },
472
- },
473
- {
474
- where: {
475
- value: "LRS2",
476
- },
477
- create: {
478
- value: "LRS2",
479
- name: "Ladle Repair shop road 2",
480
- },
481
- },
482
- {
483
- where: {
484
- value: "KLO",
485
- },
486
- create: {
487
- value: "KLO",
488
- name: "Klondu",
489
- },
490
- },
491
- ],
492
- },
493
208
  },
494
209
  });
210
+
211
+ // R+M Break
495
212
  const createRM = await prisma.station.create({
496
213
  data: {
497
214
  value: "R+M/BREAK",
498
215
  name: "R+M / Break",
499
- locations: {
500
- connectOrCreate: [
501
- {
502
- where: {
503
- value: "LRS1",
504
- },
505
- create: {
506
- value: "LRS1",
507
- name: "Ladle Repair shop road 1",
508
- },
509
- },
510
- {
511
- where: {
512
- value: "LRS2",
513
- },
514
- create: {
515
- value: "LRS2",
516
- name: "Ladle Repair shop road 2",
517
- },
518
- },
519
- ],
520
- },
521
216
  },
522
217
  });
523
218
 
@@ -538,7 +233,110 @@ async function main() {
538
233
  createWB2,
539
234
  createWB2H,
540
235
  });
236
+ }
237
+
238
+ // SEED: Connect the locations to stations
239
+ const holdingLocations: { value: string; name: string }[] = [
240
+ { value: "WPR", name: "Woodpecker Repair Lines" },
241
+ { value: "5OL", name: "5 Outside Loop" },
242
+ { value: "5BF", name: "5 Blast Furnace" },
243
+ { value: "OPM", name: "Old Plug Mill" },
244
+ { value: "XOVR", name: "Short Cross Over" },
245
+ { value: "5ML", name: "5 BF Middle Loop" },
246
+ { value: "6BF", name: "6 Blast Furnace" },
247
+ { value: "DSML", name: "Desulph Main Line" },
248
+ { value: "SPUR", name: "Stripper Spur" },
249
+ ];
250
+ await addLocationsToStation("HOLDING", holdingLocations);
251
+
252
+ const _5BFELocations: { value: string; name: string }[] = [
253
+ { value: "5BFE", name: "5 Blast Furnace - East" },
254
+ ];
255
+ await addLocationsToStation("5BFE", _5BFELocations);
256
+
257
+ const _5BFNLocations: { value: string; name: string }[] = [
258
+ { value: "5BFN", name: "5 Blast Furnace - North" },
259
+ ];
260
+ await addLocationsToStation("5BFN", _5BFNLocations);
261
+
262
+ const _5BFWLocations: { value: string; name: string }[] = [
263
+ { value: "5BFW", name: "5 Blast Furnace - West" },
264
+ ];
265
+ await addLocationsToStation("5BFW", _5BFWLocations);
266
+
267
+ const DES1Locations: { value: string; name: string }[] = [
268
+ { value: "DES1", name: "Desulphurisation 1" },
269
+ ];
270
+ await addLocationsToStation("DES1", DES1Locations);
271
+
272
+ const DES2Locations: { value: string; name: string }[] = [
273
+ { value: "DES2", name: "Desulphurisation 2" },
274
+ ];
275
+ await addLocationsToStation("DES2", DES2Locations);
276
+
277
+ const _6PITLocations: { value: string; name: string }[] = [
278
+ { value: "6PIT", name: "6 Pit" },
279
+ ];
280
+ await addLocationsToStation("6PIT", _6PITLocations);
281
+
282
+ const WB1Locations: { value: string; name: string }[] = [
283
+ { value: "WB1", name: "Weighbridge 1" },
284
+ ];
285
+ await addLocationsToStation("WB1", WB1Locations);
541
286
 
287
+ const WB2Locations: { value: string; name: string }[] = [
288
+ { value: "WB2", name: "Weighbridge 2" },
289
+ ];
290
+ await addLocationsToStation("WB2", WB2Locations);
291
+
292
+ const _21DumpLocations: { value: string; name: string }[] = [
293
+ { value: "21D", name: "Dump" },
294
+ ];
295
+ await addLocationsToStation("21D", _21DumpLocations);
296
+
297
+ const WB1HLocations: { value: string; name: string }[] = [
298
+ { value: "WB1H", name: "Weighbridge 1 - Holding" },
299
+ ];
300
+ await addLocationsToStation("WB1H", WB1HLocations);
301
+
302
+ const WB2HLocations: { value: string; name: string }[] = [
303
+ { value: "WB2H", name: "Weighbridge 2 - Holding" },
304
+ ];
305
+ await addLocationsToStation("WB2H", WB2HLocations);
306
+
307
+ const GASLocations: { value: string; name: string }[] = [
308
+ { value: "GASL", name: "Gasline" },
309
+ { value: "COOL", name: "Cooling Station" },
310
+ { value: "5BFHL", name: "No.5 Blast Furnace Heating line" },
311
+ ];
312
+ await addLocationsToStation("GAS", GASLocations);
313
+
314
+ const OOSLocations: { value: string; name: string }[] = [
315
+ { value: "GASL", name: "Gasline" },
316
+ { value: "COOL", name: "Cooling Station" },
317
+ { value: "5BFHL", name: "No.5 Blast Furnace Heating line" },
318
+ { value: "5FDRY", name: "No.5 position Foundry" },
319
+ { value: "GUNR", name: "Gunning Road" },
320
+ { value: "AWNR", name: "Awning Road" },
321
+ { value: "REBS", name: "Rebrick shed" },
322
+ { value: "LRS1", name: "Ladle Repair shop road 1" },
323
+ { value: "LRS2", name: "Ladle Repair shop road 2" },
324
+ { value: "KLO", name: "Klondu" },
325
+ { value: "WPR", name: "Woodpecker Repair Lines" },
326
+ { value: "SPUR", name: "Stripper Spur" },
327
+ ];
328
+ await addLocationsToStation("OOS", OOSLocations);
329
+
330
+ const RMLocations: { value: string; name: string }[] = [
331
+ { value: "LRS1", name: "Ladle Repair shop road 1" },
332
+ { value: "LRS2", name: "Ladle Repair shop road 2" },
333
+ ];
334
+ await addLocationsToStation("R+M/BREAK", RMLocations);
335
+
336
+ // Set Random Stations and Locations for Torpedoes
337
+ if ((await prisma.torpedoLocation.count()) > 0) {
338
+ console.log("SEED: Station - skipped.");
339
+ } else {
542
340
  const torpedoIdList = await prisma.torpedo.findMany({
543
341
  select: {
544
342
  torpedoId: true,