<?php
declare(strict_types=1);

require_once __DIR__ . '/backup_service.php';

function golder_ensure_job_runs_table(PDO $master): void
{
    $master->exec(
        "CREATE TABLE IF NOT EXISTS job_runs (
            id BIGINT AUTO_INCREMENT PRIMARY KEY,
            job_name VARCHAR(120) NOT NULL,
            status VARCHAR(20) NOT NULL,
            details_json JSON,
            started_at DATETIME NOT NULL,
            finished_at DATETIME DEFAULT NULL,
            created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
            KEY idx_job_started (job_name, started_at),
            KEY idx_status_started (status, started_at)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
    );
}


