mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-26 01:09:02 -05:00
* Migrate code to new weapon list type * Add database migration script * Run formatter * Display favorite background image * Null latest weapon on empty array
24 lines
515 B
JavaScript
24 lines
515 B
JavaScript
export function up(db) {
|
|
db.transaction(() => {
|
|
const users = db
|
|
.prepare(/* sql */ "SELECT id, qWeaponPool FROM User")
|
|
.all();
|
|
|
|
const updateStatement = db.prepare(
|
|
/* sql */ "UPDATE User SET qWeaponPool = ? WHERE id = ?",
|
|
);
|
|
|
|
for (const user of users) {
|
|
if (!user.qWeaponPool) continue;
|
|
|
|
const pool = JSON.parse(user.qWeaponPool);
|
|
const newPool = pool.map((id) => ({
|
|
weaponSplId: id,
|
|
isFavorite: 0,
|
|
}));
|
|
|
|
updateStatement.run(JSON.stringify(newPool), user.id);
|
|
}
|
|
})();
|
|
}
|