<?php
define('ROOT_PATH', dirname(__DIR__));
require_once ROOT_PATH . '/app/core/Autoloader.php';
\App\Core\Autoloader::register();

$bootstrap = new \App\Core\Bootstrap();
$bootstrap->init();

use App\Core\Database;

try {
    $db = Database::getConnection();
    
    $opModel = new \App\Modules\Operation\OperationModel();
    $opModel->ensurePilotEventsExist(83);
    $opModel->migrateExistingGuestsEvents(83);
    
    $stmt = $db->query('SELECT id, event_name, workspace_id, is_deleted FROM wedding_events');
    $events = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    foreach ($events as $e) {
        echo "ID: {$e['id']} | Name: {$e['event_name']} | Workspace ID: {$e['workspace_id']} | Deleted: {$e['is_deleted']}\n";
    }
    
    $stmt2 = $db->query('SELECT id, full_name, guest_code FROM guests WHERE full_name LIKE "%Charlie%"');
    $guests = $stmt2->fetchAll(PDO::FETCH_ASSOC);
    echo "\n--- Charlie Guests ---\n";
    foreach ($guests as $g) {
        echo "ID: {$g['id']} | Name: {$g['full_name']} | Code: {$g['guest_code']}\n";
    }
} catch (Throwable $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
