gohorsejobs/seeder-api/src/run_migration.js
Tiago Yamamoto 1c7ef95c1a first commit
2025-12-09 19:04:48 -03:00

26 lines
771 B
JavaScript

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();