This commit is contained in:
Your Name committed 2026-06-28 01:40:45 -04:00
1 parent 6a35dcf955
commit b362f5cadf
10 files changed
+335 -78

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
await prisma.product.updateMany({
data: {
price: null,
},
});
console.log('Successfully set all Product prices to null');
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/expect -f
set timeout -1
spawn bunx prisma migrate dev --name remove_product_price
expect {
"We need to reset" { send "y\r"; exp_continue }
"Are you sure you want to create this migration?" { send "y\r"; exp_continue }
"(y/N)" { send "y\r"; exp_continue }
"(y/n)" { send "y\r"; exp_continue }
eof
}
+19
View File
@@ -0,0 +1,19 @@
import pty
import os
import sys
pid, fd = pty.fork()
if pid == 0:
os.execvp("bun", ["bun", "run", "./node_modules/.bin/prisma", "migrate", "dev", "--name", "remove_product_price"])
else:
while True:
try:
output = os.read(fd, 1024)
if not output: break
sys.stdout.write(output.decode('utf-8', 'ignore'))
sys.stdout.flush()
lower_out = output.lower()
if b"(y/n)" in lower_out or b"reset" in lower_out:
os.write(fd, b"y\n")
except OSError:
break
@@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the column `price` on the `Product` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Product" DROP COLUMN "price";
-1
View File
@@ -55,7 +55,6 @@ model CategoryTranslation {
model Product {
id Int @id @default(autoincrement())
price Float? @default(0)
categoryId Int
category Category @relation(fields: [categoryId], references: [id])
name String?
+7
View File
@@ -312,6 +312,13 @@ export const productsRoute = new Elysia({ prefix: "/products" })
option2: v.option2 || "",
option3: v.option3 || "",
price: v.price || 0,
bomItems: v.bomItems ? {
deleteMany: {},
create: v.bomItems.map((b: any) => ({
rawMaterialId: b.rawMaterialId,
quantity: b.quantity,
}))
} : undefined
}
});
}