const db = require('../db');

async function createTable() {
    try {
        await db.query(`
            CREATE TABLE IF NOT EXISTS seo_metadata (
                id INT AUTO_INCREMENT PRIMARY KEY,
                route VARCHAR(255) UNIQUE NOT NULL,
                title VARCHAR(255),
                description TEXT,
                keywords VARCHAR(255),
                og_image VARCHAR(255),
                updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
            )
        `);
        
        // Insert a few default routes to start
        try {
            await db.query(`
                INSERT IGNORE INTO seo_metadata (route, title, description) VALUES
                ('/home', 'InfoSecLabs | SOC Analyst Training & Cybersecurity Academy', 'Master cybersecurity with hands-on labs, realistic SOC simulations, and expert-led training.'),
                ('/pricing', 'Pricing & Plans | Pro SOC Analyst Training', 'Upgrade to InfoSecLabs Pro. Get unlimited access to hands-on cybersecurity labs.'),
                ('/academy', 'SOC Analyst Academy | Hands-on Cybersecurity Labs', 'Master cybersecurity with our structured SOC Analyst training paths.'),
                ('/faq', 'Cybersecurity Training FAQ | InfoSecLabs SOC Analyst Bootcamp', 'Find answers to common questions about our SOC Analyst training.')
            `);
        } catch(e) {}
        
        console.log("seo_metadata table created successfully!");
    } catch (error) {
        console.error("Error creating table:", error);
    } finally {
        process.exit();
    }
}

createTable();
