// One-off price refresh. Run with: npx tsx prisma/update-prices.ts // Idempotent: upserts every row, safe to re-run. import { PrismaClient } from '../src/generated/prisma/client.js'; import { PrismaLibSql } from '@prisma/adapter-libsql'; import path from 'path'; const dbPath = path.resolve(process.cwd(), 'prisma', 'lootah.db'); const adapter = new PrismaLibSql({ url: `file:${dbPath}` }); const prisma = new PrismaClient({ adapter } as ConstructorParameters[0]); const items = [ { id: 'base', label: 'G1 Robot Basic', price: 77125, sortOrder: 0 }, { id: 'edu', label: 'G1 Robot EDU', price: 146900, sortOrder: 1 }, { id: 'emarati-kandura', label: 'Emarati Kandura', price: 5000, sortOrder: 2 }, { id: 'industrial-vest', label: 'Industrial Vest', price: 5000, sortOrder: 3 }, { id: 'business-suit', label: 'Business Suit', price: 5000, sortOrder: 4 }, { id: 'custom-color', label: 'Custom Color', price: 3500, sortOrder: 5 }, { id: 'robot-doctor', label: 'Robot Doctor', price: 5000, sortOrder: 6 }, { id: 'security-guard', label: 'Security Guard', price: 5000, sortOrder: 7 }, ]; async function main() { for (const item of items) { await prisma.pricingItem.upsert({ where: { id: item.id }, create: item, update: { label: item.label, price: item.price, sortOrder: item.sortOrder }, }); console.log(`✓ ${item.id} → ${item.label} @ ${item.price} AED`); } } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });