Files
gpatruno 2614d679c8 update
2026-07-18 16:26:08 +02:00

39 lines
902 B
JavaScript

/**
* Backfill existing InventoryItem rows with FT mid float + catalog marketValue.
* Run after: npx prisma db push
*
* npm run db:backfill-wear --prefix server
*/
import { prisma } from '../src/db.js';
import { FT_MID_FLOAT } from '../src/wear.js';
async function main() {
const rows = await prisma.inventoryItem.findMany({
include: { item: true },
});
let updated = 0;
for (const inv of rows) {
if (inv.valueCents !== 0) continue;
await prisma.inventoryItem.update({
where: { id: inv.id },
data: {
floatValue: FT_MID_FLOAT,
wear: 'Field-Tested',
paintSeed: 0,
valueCents: inv.item.marketValue,
},
});
updated += 1;
}
console.log(`Backfilled ${updated} / ${rows.length} inventory items`);
}
main()
.catch((err) => {
console.error(err);
process.exit(1);
})
.finally(() => prisma.$disconnect());