SELECT table_name FROM information_schema.tables
WHERE table_schema = DATABASE()
  AND table_name IN ('qipai_permissions', 'qipai_roles', 'qipai_role_permissions',
                     'qipai_user_roles', 'qipai_user_store_scopes')
ORDER BY table_name;

SELECT table_name, index_name FROM information_schema.statistics
WHERE table_schema = DATABASE()
  AND ((table_name = 'qipai_permissions' AND index_name = 'uq_qipai_permissions_code')
    OR (table_name = 'qipai_roles' AND index_name = 'uq_qipai_roles_tenant_code')
    OR (table_name = 'qipai_user_store_scopes' AND index_name = 'idx_qipai_user_store_scopes_store'))
GROUP BY table_name, index_name ORDER BY table_name, index_name;

SELECT code FROM qipai_permissions
WHERE code IN ('profile.read', 'order.self.read', 'cleaning.task.read',
               'store.operation.read', 'store.operation.write', 'tenant.manage', 'platform.manage')
ORDER BY code;

SELECT version, name FROM qipai_schema_migrations WHERE version = '2026061805';
