CREATE TABLE IF NOT EXISTS import_jobs (
    id              INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    filename        VARCHAR(255) NOT NULL,
    original_name   VARCHAR(255) NOT NULL DEFAULT '',
    mapping         JSON NOT NULL,
    options         JSON NOT NULL,
    status          ENUM('pending','processing','completed','cancelled','failed') NOT NULL DEFAULT 'pending',
    total_rows      INT UNSIGNED NOT NULL DEFAULT 0,
    processed_rows  INT UNSIGNED NOT NULL DEFAULT 0,
    imported_count  INT UNSIGNED NOT NULL DEFAULT 0,
    skipped_count   INT UNSIGNED NOT NULL DEFAULT 0,
    error_count     INT UNSIGNED NOT NULL DEFAULT 0,
    error_message   TEXT DEFAULT NULL,
    user_id         INT UNSIGNED NOT NULL,
    created_at      DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at      DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    started_at      DATETIME DEFAULT NULL,
    completed_at    DATETIME DEFAULT NULL,
    INDEX idx_status (status),
    INDEX idx_updated (updated_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
