-- ============================================================
-- NICC Admin Menu - Migracion 0012
-- Agregar enlace a Wasabi S3 Sync (solo visible para manager)
-- ============================================================

INSERT OR IGNORE INTO admin_menu_items (
    category_id,
    code,
    plugin_name,
    name,
    description,
    icon,
    url,
    sort_order,
    is_active,
    is_dangerous,
    requires_confirmation
)
SELECT
    (SELECT id FROM admin_menu_categories WHERE code = 'tools' LIMIT 1),
    'wasabisync',
    'wasabisync',
    'Wasabi S3 Sync',
    'Estadisticas, prueba de conexion y migracion de archivos a Wasabi S3',
    'cloud',
    '?do=admin&page=wasabisync',
    60,
    1,
    0,
    0
WHERE NOT EXISTS (SELECT 1 FROM admin_menu_items WHERE code = 'wasabisync');

-- Manager: acceso total
INSERT OR REPLACE INTO admin_menu_permissions (item_id, role, can_view, can_execute)
SELECT id, 'manager', 1, 1 FROM admin_menu_items WHERE code = 'wasabisync';

-- Admin: oculto
INSERT OR REPLACE INTO admin_menu_permissions (item_id, role, can_view, can_execute)
SELECT id, 'admin', 0, 0 FROM admin_menu_items WHERE code = 'wasabisync';

-- Superuser: oculto
INSERT OR REPLACE INTO admin_menu_permissions (item_id, role, can_view, can_execute)
SELECT id, 'superuser', 0, 0 FROM admin_menu_items WHERE code = 'wasabisync';

-- Fin de migracion
SELECT 1;
