const { db, playerHelpers } = require('./sqlite-db'); // Update all player passwords to environment default function updateAllPasswords() { try { // First check the table structure const columns = db.prepare("PRAGMA table_info(players)").all(); console.log('Table columns:', columns.map(c => c.name)); // Update only the pw column (pwHash might not exist) const defaultPassword = process.env.PLAYER_PASSWORD || 'defaultpassword'; const updateStmt = db.prepare('UPDATE players SET pw = ?'); const result = updateStmt.run(defaultPassword); console.log(`Updated ${result.changes} player passwords to environment default`); // Verify the changes const players = playerHelpers.getAll(); console.log('Current players:'); players.forEach(player => { console.log(`- ${player.name}: pw="${player.pw}"`); }); } catch (error) { console.error('Error updating passwords:', error); } finally { db.close(); } } updateAllPasswords();