USE hm;
ALTER TABLE tareas ADD COLUMN IF NOT EXISTS avance TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER estado;
CREATE TABLE IF NOT EXISTS tarea_adjuntos (
 id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
 tarea_id INT UNSIGNED NOT NULL,
 seguimiento_id INT UNSIGNED NULL,
 nombre_original VARCHAR(255) NOT NULL,
 nombre_archivo VARCHAR(255) NOT NULL,
 mime VARCHAR(150) NULL,
 tamano INT UNSIGNED NOT NULL DEFAULT 0,
 usuario_id INT UNSIGNED NULL,
 creado_en DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
 INDEX idx_adj_tarea(tarea_id),
 CONSTRAINT fk_adj_tarea FOREIGN KEY(tarea_id) REFERENCES tareas(id) ON DELETE CASCADE,
 CONSTRAINT fk_adj_seg FOREIGN KEY(seguimiento_id) REFERENCES tarea_seguimientos(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
