@bslau/hmm_prisma_schema 1.10.1 → 1.11.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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
BEGIN TRY
|
|
2
|
+
|
|
3
|
+
BEGIN TRAN;
|
|
4
|
+
|
|
5
|
+
-- AlterTable
|
|
6
|
+
ALTER TABLE [dbo].[HotMetal] ADD [hotMetalStateId] INT;
|
|
7
|
+
|
|
8
|
+
-- CreateTable
|
|
9
|
+
CREATE TABLE [dbo].[HotMetalState] (
|
|
10
|
+
[id] INT NOT NULL IDENTITY(1,1),
|
|
11
|
+
[name] NVARCHAR(1000) NOT NULL,
|
|
12
|
+
[label] NVARCHAR(1000) NOT NULL,
|
|
13
|
+
[description] NVARCHAR(1000) NOT NULL,
|
|
14
|
+
CONSTRAINT [HotMetalState_pkey] PRIMARY KEY CLUSTERED ([id]),
|
|
15
|
+
CONSTRAINT [HotMetalState_name_key] UNIQUE NONCLUSTERED ([name])
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
-- AddForeignKey
|
|
19
|
+
ALTER TABLE [dbo].[HotMetal] ADD CONSTRAINT [HotMetal_hotMetalStateId_fkey] FOREIGN KEY ([hotMetalStateId]) REFERENCES [dbo].[HotMetalState]([id]) ON DELETE SET NULL ON UPDATE CASCADE;
|
|
20
|
+
|
|
21
|
+
COMMIT TRAN;
|
|
22
|
+
|
|
23
|
+
END TRY
|
|
24
|
+
BEGIN CATCH
|
|
25
|
+
|
|
26
|
+
IF @@TRANCOUNT > 0
|
|
27
|
+
BEGIN
|
|
28
|
+
ROLLBACK TRAN;
|
|
29
|
+
END;
|
|
30
|
+
THROW
|
|
31
|
+
|
|
32
|
+
END CATCH
|
package/prisma/schema.prisma
CHANGED
|
@@ -229,6 +229,8 @@ model HotMetal {
|
|
|
229
229
|
alPucksAdded Boolean @default(false)
|
|
230
230
|
integrationStage Int @default(0)
|
|
231
231
|
pourStatus Int @default(0)
|
|
232
|
+
hotMetalState HotMetalState? @relation(fields: [hotMetalStateId], references: [id])
|
|
233
|
+
hotMetalStateId Int?
|
|
232
234
|
createdAt DateTime @default(now())
|
|
233
235
|
updatedAt DateTime @updatedAt
|
|
234
236
|
|
|
@@ -265,6 +267,17 @@ model HotMetalLabResult {
|
|
|
265
267
|
updatedAt DateTime @updatedAt
|
|
266
268
|
}
|
|
267
269
|
|
|
270
|
+
/// **HOT METAL STATE**
|
|
271
|
+
///
|
|
272
|
+
/// Describes a valid operational _State_ that a _HotMetal_ batch can be assigned.
|
|
273
|
+
model HotMetalState {
|
|
274
|
+
id Int @id @default(autoincrement())
|
|
275
|
+
name String @unique
|
|
276
|
+
label String
|
|
277
|
+
description String
|
|
278
|
+
hotMetalCollection HotMetal[]
|
|
279
|
+
}
|
|
280
|
+
|
|
268
281
|
/// **LOCATION**
|
|
269
282
|
///
|
|
270
283
|
/// An operational location where _Torpedoes_ may be placed during use.
|
package/prisma/seed.ts
CHANGED
|
@@ -565,6 +565,24 @@ async function main() {
|
|
|
565
565
|
createNotificationSource,
|
|
566
566
|
});
|
|
567
567
|
}
|
|
568
|
+
|
|
569
|
+
// SEED: HotMetalState
|
|
570
|
+
if ((await prisma.hotMetalState.count()) > 0) {
|
|
571
|
+
console.log("SEED: HotMetalState - skipped.");
|
|
572
|
+
} else {
|
|
573
|
+
console.log("SEED: HotMetalState - generating...");
|
|
574
|
+
|
|
575
|
+
const createHotMetalState = await prisma.hotMetalState.createMany({
|
|
576
|
+
data: [
|
|
577
|
+
{ name: "BLEND", label: "Blended", description: "Composed of material from multiple sources" },
|
|
578
|
+
{ name: "REJECT", label: "Rejected", description: "Insufficient material for measurement" },
|
|
579
|
+
],
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
console.log({
|
|
583
|
+
createHotMetalState,
|
|
584
|
+
});
|
|
585
|
+
}
|
|
568
586
|
}
|
|
569
587
|
|
|
570
588
|
main()
|