-- Agrega control de edicion de descripcion por item

SET @sql_add_desc_editable := (
    SELECT IF(
        COUNT(*) = 0,
        'ALTER TABLE catalogo_items ADD COLUMN descripcion_editable TINYINT(1) NOT NULL DEFAULT 0 AFTER afectacion_igv_id',
        'SELECT 1'
    )
    FROM information_schema.columns
    WHERE table_schema = DATABASE()
      AND table_name = 'catalogo_items'
      AND column_name = 'descripcion_editable'
);
PREPARE stmt_add_desc_editable FROM @sql_add_desc_editable;
EXECUTE stmt_add_desc_editable;
DEALLOCATE PREPARE stmt_add_desc_editable;
