const db = require('./config/database');
const bcrypt = require('bcryptjs');

async function fixTestUserPassword() {
  try {
    const hashedPassword = await bcrypt.hash('111', 10);
    
    // Update school@test.com password
    await db.execute(
      'UPDATE users SET password_hash = ? WHERE email = ? AND user_type = ?',
      [hashedPassword, 'school@test.com', 'school']
    );
    
    console.log('Updated password for school@test.com to "111"');
    
    // Verify
    const [rows] = await db.execute('SELECT password_hash FROM users WHERE email = ?', ['school@test.com']);
    const isValid = await bcrypt.compare('111', rows[0].password_hash);
    console.log(`school@test.com: password "111" valid = ${isValid}`);
    
    process.exit(0);
  } catch (error) {
    console.error('Error:', error);
    process.exit(1);
  }
}

fixTestUserPassword();