Some checks failed
Test and deploy staging / staging (push) Failing after 5m29s
24 lines
960 B
TypeScript
24 lines
960 B
TypeScript
import postgres from 'postgres';
|
|
import artwork from '../data/cod-art.json';
|
|
import achievementArt from '../data/cod-achievement-art.json';
|
|
|
|
if (!process.env.DB_URL) throw new Error('DB_URL is required');
|
|
const sql = postgres(process.env.DB_URL, { max: 1 });
|
|
try {
|
|
await sql.begin(async (tx) => {
|
|
for (const image of artwork) {
|
|
const rows =
|
|
await tx`update tracker_items i set icon=${image.path} from tracker_games g where i.game_id=g.id and g.slug=${image.game} and i.key=${image.key} returning i.id`;
|
|
if (rows.length !== 1) throw new Error(`Unknown artwork target: ${image.game}/${image.key}`);
|
|
}
|
|
for (const [source, path] of Object.entries(achievementArt)) {
|
|
await tx`update tracker_items set icon=${path} where kind='achievement' and icon=${source}`;
|
|
}
|
|
});
|
|
console.log(
|
|
`Seeded ${artwork.length} weapon pictures and ${Object.keys(achievementArt).length} achievement icons; progress preserved.`
|
|
);
|
|
} finally {
|
|
await sql.end();
|
|
}
|