CREATE TABLE IF NOT EXISTS `site_visits` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `visitor_key` CHAR(64) NOT NULL,
    `path` VARCHAR(190) NOT NULL,
    `query_string` VARCHAR(255) DEFAULT NULL,
    `referrer` VARCHAR(255) DEFAULT NULL,
    `user_agent` VARCHAR(255) DEFAULT NULL,
    `ip_hash` CHAR(64) DEFAULT NULL,
    `visited_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `idx_site_visits_visited_at` (`visited_at`),
    KEY `idx_site_visits_path` (`path`),
    KEY `idx_site_visits_visitor_key` (`visitor_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;