SET QUOTED_IDENTIFIER ON;
GO

PRINT '=== Identity table names ===';
SELECT name FROM sys.tables WHERE name LIKE '%Role%' OR name LIKE '%User%';
GO

PRINT '=== Admin role permissions for catalog menu ===';
SELECT P.MenuKey, P.CanRead, P.CanCreate, P.CanUpdate, P.CanDelete
FROM Permissions P
INNER JOIN Roles R ON R.Id = P.RoleId
WHERE R.Name = 'Admin'
  AND P.MenuKey IN ('Master','Suppliers','Projects','Departments','Catalogs','CatalogUnits','CatalogMaterials','CatalogServices','CatalogWorkItems')
ORDER BY P.MenuKey;
GO

PRINT '=== ALL Admin permissions count ===';
SELECT COUNT(*) AS AdminPermCount
FROM Permissions P
INNER JOIN Roles R ON R.Id = P.RoleId
WHERE R.Name = 'Admin';
GO

PRINT '=== CatalogManager role permissions ===';
SELECT P.MenuKey, P.CanRead, P.CanCreate, P.CanUpdate, P.CanDelete
FROM Permissions P
INNER JOIN Roles R ON R.Id = P.RoleId
WHERE R.Name = 'CatalogManager'
ORDER BY P.MenuKey;
GO
