-- ============================================================
-- NICC Admin Menu - Migracion 0002
-- Reorganizar menu segun especificaciones
-- ============================================================

-- Actualizar orden de categorias:
-- 1. Usuarios y Permisos
-- 2. Sistema y Configuracion
-- 3. Modulos NICC
-- 4. Herramientas (sin zona de peligro)

UPDATE admin_menu_categories SET sort_order = 1 WHERE code = 'users';
UPDATE admin_menu_categories SET sort_order = 2 WHERE code = 'system';
UPDATE admin_menu_categories SET sort_order = 3 WHERE code = 'nicc_modules';
UPDATE admin_menu_categories SET sort_order = 4 WHERE code = 'tools';

-- Desactivar categoria "Zona de Peligro"
UPDATE admin_menu_categories SET is_active = 0 WHERE code = 'danger';

-- Desactivar categoria "Contenido y Paginas" (no mencionada)
UPDATE admin_menu_categories SET is_active = 0 WHERE code = 'content';

-- Mover "Limpiar Base de Datos" a Herramientas
UPDATE admin_menu_items
SET category_id = (SELECT id FROM admin_menu_categories WHERE code = 'tools'),
    sort_order = 3
WHERE code = 'dbcleanup';

-- Reordenar items dentro de "Usuarios y Permisos":
-- 1. Administrar Usuarios
-- 2. Permisos de Proyectos
-- 3. Control de Acceso
UPDATE admin_menu_items SET sort_order = 1 WHERE code = 'usermanager';
UPDATE admin_menu_items SET sort_order = 2 WHERE code = 'projectacl';
UPDATE admin_menu_items SET sort_order = 3 WHERE code = 'acl';

-- Reordenar items dentro de "Herramientas":
-- 1. Limpiar Historial
-- 2. Limpiar Base de Datos
-- (Quitar Revertir Cambios - no mencionado, desactivar)
UPDATE admin_menu_items SET is_active = 0 WHERE code = 'revert';
UPDATE admin_menu_items SET sort_order = 1 WHERE code = 'clearhistory';
UPDATE admin_menu_items SET sort_order = 2 WHERE code = 'dbcleanup';

-- Fin de migracion
SELECT 1;
