/** * Script pour appliquer la migration is_active aux utilisateurs */ import { pool } from '../db.js'; import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); async function applyMigration() { const client = await pool.connect(); try { console.log('🚀 DĂ©but de la migration is_active...'); // Lire le fichier SQL const sqlPath = path.join(__dirname, '../database/migrations/add-is-active-to-users.sql'); const sql = fs.readFileSync(sqlPath, 'utf8'); // ExĂ©cuter la migration await client.query(sql); console.log('✅ Migration is_active appliquĂ©e avec succĂšs!'); // VĂ©rifier le rĂ©sultat const result = await client.query('SELECT COUNT(*) as total, COUNT(CASE WHEN is_active = true THEN 1 END) as active FROM users'); console.log(`📊 Utilisateurs: ${result.rows[0].total} total, ${result.rows[0].active} actifs`); } catch (error) { console.error('❌ Erreur lors de la migration:', error.message); throw error; } finally { client.release(); await pool.end(); } } applyMigration();