-- ============================================================
-- Migracja 009: Etap 6 - operacje systemowe (cron/backup/SEO)
-- Tartak Dana CMS
-- Kompatybilność: MySQL 8.0
-- ============================================================

SET NAMES utf8mb4;

-- -----------------------------------------------------------
-- Log uruchomień zadań systemowych (cron/manual)
-- -----------------------------------------------------------
CREATE TABLE IF NOT EXISTS `system_job_runs` (
    `id`           BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `job_key`      VARCHAR(64)     NOT NULL,
    `status`       ENUM('success','failed') NOT NULL DEFAULT 'success',
    `output_text`  TEXT            NULL,
    `duration_ms`  INT UNSIGNED    NOT NULL DEFAULT 0,
    `created_at`   DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    INDEX `idx_system_job_key_created` (`job_key`, `created_at`),
    INDEX `idx_system_job_created` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

