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 runMigration() { try { const migrationPath = path.resolve(__dirname, '../../backend/migrations/999_fix_gohorse_schema.sql'); console.log(`Reading migration from: ${migrationPath}`); const sql = fs.readFileSync(migrationPath, 'utf8'); console.log('Running migration...'); await pool.query(sql); console.log('✅ Migration executed successfully'); } catch (error) { console.error('❌ Migration failed:', error); } finally { await pool.end(); } } runMigration();