-- =====================================================
-- MODULO DE TAREAS MASIVAS - REVERSION
-- Migracion: update0022.sql
-- Fecha: 2026-02-09
-- Descripcion: Columnas para reversion de cargas masivas
-- =====================================================

-- Crear tabla bulk_task_log si no existe
CREATE TABLE IF NOT EXISTS bulk_task_log (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    project_id INTEGER DEFAULT 0,
    filename TEXT NOT NULL,
    tasks_created INTEGER DEFAULT 0,
    tasks_skipped INTEGER DEFAULT 0,
    errors INTEGER DEFAULT 0,
    uploaded_by TEXT NOT NULL,
    uploaded_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    task_ids TEXT DEFAULT NULL,
    reverted INTEGER DEFAULT 0,
    reverted_at DATETIME DEFAULT NULL,
    reverted_by TEXT DEFAULT NULL
);

-- Agregar columnas si la tabla ya existe (SQLite ignora si ya existen)
-- Nota: ALTER TABLE ADD COLUMN falla si la columna existe,
-- pero el plugin sqlite maneja esto internamente
