import { pool } from '../config/database';

async function migrate() {
  try {
    console.log('Starting migration...');
    const query = `ALTER TABLE users ADD COLUMN must_change_password BOOLEAN DEFAULT FALSE AFTER password_hash;`;
    await pool.query(query);
    console.log('Migration completed successfully: must_change_password added.');
  } catch (error: any) {
    if (error.code === 'ER_DUP_FIELDNAME') {
      console.log('Column must_change_password already exists.');
    } else {
      console.error('Migration failed:', error);
    }
  } finally {
    process.exit(0);
  }
}

migrate();
