@bslau/hmm_prisma_schema 1.18.1 → 1.19.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 +4 -3
- package/prisma/{functions/deleteTorpedo.ts → deleteTorpedo.ts} +2 -2
- package/prisma/fillNullSegmentResponseIds.ts +22 -0
- package/prisma/migrations/20251203060958_prisma_fill_the_segment_response_id_field_with_unique_ids/migration.sql +29 -0
- package/prisma/schema.prisma +1 -1
- package/prisma/seed.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bslau/hmm_prisma_schema",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"author": "CIPA Development Team",
|
|
6
6
|
"license": "ISC",
|
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
"types": "./index.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"prisma": "6.2.1",
|
|
24
|
-
"
|
|
23
|
+
"@prisma/client": "6.2.1",
|
|
24
|
+
"prisma": "6.2.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^22.12.0",
|
|
28
28
|
"@types/underscore": "^1.13.0",
|
|
29
|
+
"dotenv": "^17.2.3",
|
|
29
30
|
"ts-node": "^10.9.2",
|
|
30
31
|
"tsx": "^4.19.2",
|
|
31
32
|
"typescript": "^5.7.3",
|
|
@@ -101,7 +101,7 @@ async function deleteTorpedo(torpedoId: number) {
|
|
|
101
101
|
// 9️⃣ DELETE TORPEDO LAST
|
|
102
102
|
//
|
|
103
103
|
await tx.torpedo.delete({
|
|
104
|
-
where: {
|
|
104
|
+
where: { torpedoId: torpedoId },
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
107
|
|
|
@@ -113,7 +113,7 @@ async function main() {
|
|
|
113
113
|
|
|
114
114
|
if (!param) {
|
|
115
115
|
console.error("❌ Please provide a torpedo number.");
|
|
116
|
-
console.error("Usage: npx
|
|
116
|
+
console.error("Usage: npx ts-node -r dotenv/config prisma/deleteTorpedo.ts <torpedoNumber>");
|
|
117
117
|
process.exit(1);
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import prisma from "./dbClient";
|
|
2
|
+
|
|
3
|
+
async function fillNullSegmentResponseIds() {
|
|
4
|
+
const resultFillSegmentResponseId = await prisma.$executeRaw`
|
|
5
|
+
UPDATE [HotMetal]
|
|
6
|
+
SET [segmentResponseId] = [id]
|
|
7
|
+
WHERE [segmentResponseId] IS null
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
console.log(`Row updated: ${resultFillSegmentResponseId}`)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
fillNullSegmentResponseIds()
|
|
14
|
+
.then(async () => {
|
|
15
|
+
await prisma.$disconnect()
|
|
16
|
+
})
|
|
17
|
+
.catch(async (e) => {
|
|
18
|
+
console.error("❌ Error:", e)
|
|
19
|
+
await prisma.$disconnect()
|
|
20
|
+
process.exit(1)
|
|
21
|
+
})
|
|
22
|
+
.finally(() => prisma.$disconnect());
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- A unique constraint covering the columns `[segmentResponseId]` on the table `HotMetal` will be added. If there are existing duplicate values, this will fail.
|
|
5
|
+
- Made the column `segmentResponseId` on table `HotMetal` required. This step will fail if there are existing NULL values in that column.
|
|
6
|
+
|
|
7
|
+
*/
|
|
8
|
+
BEGIN TRY
|
|
9
|
+
|
|
10
|
+
BEGIN TRAN;
|
|
11
|
+
|
|
12
|
+
-- AlterTable
|
|
13
|
+
ALTER TABLE [dbo].[HotMetal] ALTER COLUMN [segmentResponseId] NVARCHAR(1000) NOT NULL;
|
|
14
|
+
|
|
15
|
+
-- CreateIndex
|
|
16
|
+
ALTER TABLE [dbo].[HotMetal] ADD CONSTRAINT [HotMetal_segmentResponseId_key] UNIQUE NONCLUSTERED ([segmentResponseId]);
|
|
17
|
+
|
|
18
|
+
COMMIT TRAN;
|
|
19
|
+
|
|
20
|
+
END TRY
|
|
21
|
+
BEGIN CATCH
|
|
22
|
+
|
|
23
|
+
IF @@TRANCOUNT > 0
|
|
24
|
+
BEGIN
|
|
25
|
+
ROLLBACK TRAN;
|
|
26
|
+
END;
|
|
27
|
+
THROW
|
|
28
|
+
|
|
29
|
+
END CATCH
|
package/prisma/schema.prisma
CHANGED
|
@@ -268,7 +268,7 @@ model HotMetal {
|
|
|
268
268
|
alPucksAdded Boolean @default(false)
|
|
269
269
|
integrationStage Int @default(0)
|
|
270
270
|
pourStatus Int @default(0)
|
|
271
|
-
segmentResponseId String
|
|
271
|
+
segmentResponseId String @unique
|
|
272
272
|
hotMetalState HotMetalState? @relation(fields: [hotMetalStateId], references: [id])
|
|
273
273
|
hotMetalStateId Int?
|
|
274
274
|
hotMetalPouredCollection HotMetalPoured[]
|