SELECT 'TABLAS_GENEACASE' AS prueba, COUNT(*) AS total
FROM information_schema.tables
WHERE table_schema = DATABASE() AND table_name LIKE 'gene_%';

SELECT 'TABLAS_MULTIEMPRESA_SIN_ID_EMPRESA' AS prueba, GROUP_CONCAT(table_name ORDER BY table_name) AS hallazgos
FROM information_schema.tables t
WHERE t.table_schema = DATABASE()
  AND (t.table_name LIKE 'gene_%' OR t.table_name LIKE 'comm_%' OR t.table_name LIKE 'billing_%')
  AND t.table_name NOT IN ('billing_planes','billing_plan_limites','billing_webhooks')
  AND NOT EXISTS (
    SELECT 1 FROM information_schema.columns c
    WHERE c.table_schema=t.table_schema AND c.table_name=t.table_name AND c.column_name='id_empresa'
  );

SELECT 'MIGRACIONES' AS prueba, COUNT(*) AS total FROM sys_migrations;
SELECT 'ROLES_SISTEMA' AS prueba, COUNT(*) AS total FROM org_roles WHERE es_sistema=1;
SELECT 'PERMISOS' AS prueba, COUNT(*) AS total FROM org_permisos;
SELECT 'PLANES_ACTIVOS' AS prueba, COUNT(*) AS total FROM billing_planes WHERE estado='activo';
