<?php
declare(strict_types=1);

use App\Core\Database;

return function (Database $db): void {
    $db->raw("
        CREATE TABLE dashboard_snapshots (
            id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            dashboard_type ENUM('club','sport','facility') NOT NULL,
            reference_id BIGINT UNSIGNED NULL,
            period_start DATE NOT NULL,
            period_end DATE NOT NULL,
            metrics_json JSON NOT NULL,
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
            INDEX idx_dash_type_period (dashboard_type, period_start, period_end)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ");
};
