// Migration: Add hostname column to ivanti_todo_queue
const sqlite3 = require('sqlite3').verbose();
const path = require('path');

const dbPath = path.join(__dirname, '..', 'cve_database.db');
const db = new sqlite3.Database(dbPath);

console.log('Starting add_todo_queue_hostname migration...');

db.run(
    'ALTER TABLE ivanti_todo_queue ADD COLUMN hostname TEXT',
    (err) => {
        if (err) {
            // Column may already exist if migration was run before
            if (err.message.includes('duplicate column name')) {
                console.log('✓ hostname column already exists, skipping');
            } else {
                console.error('Error adding column:', err);
            }
        } else {
            console.log('✓ hostname column added');
        }
        db.close(() => console.log('Migration complete!'));
    }
);
