const axios = require('axios');
const db = require('../src/db');

async function testUpdate() {
    try {
        // 1. Get a user token (login as jacob)
        // We can't easily login via script without password, but we can simulate the DB update validation directly?
        // No, we want to test the ROUTE.
        // Let's use the hardcoded token approach if I can find one, OR just trust the controller logic I read and debug frontend.
        // Actually, I can use the same logic as the migration/fix script to just invoke the DB update directly to ensure DB is writable.
        
        console.log('Testing DB Update permission...');
        await db.query("UPDATE users SET focus_area = 'red' WHERE username = 'jacob'");
        console.log('✅ DB Update successful via script.');

        // Now verify it
        const [rows] = await db.query("SELECT focus_area FROM users WHERE username = 'jacob'");
        console.log('Current Database Value:', rows[0].focus_area);

    } catch (err) {
        console.error('❌ Error:', err.message);
    }
    process.exit(0);
}

testUpdate();
