
import { Pool } from 'pg';
import dotenv from 'dotenv';
import fs from 'fs';
import path from 'path';

dotenv.config();

const pool = new Pool({
    connectionString: process.env.DATABASE_URL,
});

async function runManualMigration() {
    console.log('🔄 Running manual migration 006...');
    try {
        const client = await pool.connect();
        try {
            const sqlPath = path.join(__dirname, 'migrations/006_add_seo_scheduling.sql');
            const sql = fs.readFileSync(sqlPath, 'utf-8');
            console.log('📝 Executing SQL:', sql);
            await client.query(sql);
            console.log('✅ Migration 006 applied successfully!');
        } finally {
            client.release();
        }
    } catch (error) {
        console.error('❌ Migration 006 failed:', error);
        process.exit(1);
    } finally {
        await pool.end();
    }
}

runManualMigration();
