update
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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());
|
||||
Reference in New Issue
Block a user