<?php
require_once __DIR__ . '/../config.php';

try {
    $stmt = $pdo->prepare("
        DELETE FROM park_opening_hours
        WHERE opening_date < CURDATE()
    ");

    $stmt->execute();

    echo "Deleted " . $stmt->rowCount() . " old opening-hour rows.";
} catch (PDOException $e) {
    error_log('Opening hours cleanup failed: ' . $e->getMessage());
    http_response_code(500);
    echo "Cleanup failed.";
}