<?php

define('ROOT_PATH', dirname(__DIR__));
require_once ROOT_PATH . '/app/core/Autoloader.php';
\App\Core\Autoloader::register();
require_once ROOT_PATH . '/app/helpers/config.php';
$bootstrap = new \App\Core\Bootstrap();
$bootstrap->init();

use App\Core\Database;

try {
    $db = Database::getConnection();
    $sql = "ALTER TABLE `guests` 
            ADD COLUMN IF NOT EXISTS `view_count` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total times invitation URL was opened' AFTER `last_opened_at`";
    $db->exec($sql);
    echo "G012 guests view_count migration executed successfully.\n";
} catch (\Throwable $e) {
    echo "Migration failed: " . $e->getMessage() . "\n";
}
