-- Verify the M02-A multi-application and tenant configuration model.

SELECT table_name
FROM information_schema.tables
WHERE table_schema = DATABASE()
  AND table_name IN (
    'qipai_platform_apps',
    'qipai_tenant_apps',
    'qipai_tenant_configs'
  )
ORDER BY table_name;

SELECT table_name, index_name
FROM information_schema.statistics
WHERE table_schema = DATABASE()
  AND (
    (table_name = 'qipai_platform_apps' AND index_name = 'uq_qipai_platform_apps_appid')
    OR
    (table_name = 'qipai_tenant_apps' AND index_name IN (
      'uq_qipai_tenant_apps_tenant_app',
      'idx_qipai_tenant_apps_app_tenant'
    ))
    OR
    (table_name = 'qipai_tenant_configs' AND index_name IN (
      'uq_qipai_tenant_configs_tenant_app',
      'idx_qipai_tenant_configs_app_tenant'
    ))
  )
GROUP BY table_name, index_name
ORDER BY table_name, index_name;

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