const mysql = require('mysql2/promise');

async function checkUsersTableStructure() {
  try {
    const connection = await mysql.createConnection({
      host: 'localhost',
      user: 'root',
      password: '',
      database: 'cms_db'
    });

    console.log('🔍 Checking Users Table Structure...');
    
    // Get table structure
    const [columns] = await connection.execute('DESCRIBE users');
    
    console.log('\n📋 Users Table Columns:');
    columns.forEach(col => {
      console.log(`  ${col.Field} - ${col.Type} ${col.Null === 'NO' ? '(NOT NULL)' : '(NULL)'} ${col.Key ? `[${col.Key}]` : ''}`);
    });

    // Get Super Admin user data
    const [users] = await connection.execute('SELECT * FROM users WHERE role_id = 1 LIMIT 1');
    
    if (users.length > 0) {
      const user = users[0];
      console.log('\n👤 Super Admin User Data:');
      Object.keys(user).forEach(key => {
        console.log(`  ${key}: ${user[key]}`);
      });
    } else {
      console.log('\n❌ No Super Admin user found');
    }

    await connection.end();
  } catch (error) {
    console.error('❌ Error:', error.message);
  }
}

checkUsersTableStructure();
