SELECT table_name FROM information_schema.tables
WHERE table_schema = DATABASE() AND table_name IN (
  'qipai_payment_attempts', 'qipai_payment_callbacks', 'qipai_refunds',
  'qipai_profit_shares', 'qipai_payment_configs'
) ORDER BY table_name;

SELECT column_name FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name = 'qipai_payments'
  AND column_name IN (
    'platform_app_id', 'store_id', 'provider', 'client_request_id',
    'currency', 'provider_payment_id', 'failed_at', 'failure_code'
  ) ORDER BY column_name;

SELECT table_name, index_name FROM information_schema.statistics
WHERE table_schema = DATABASE()
  AND ((table_name = 'qipai_payments'
      AND index_name IN (
        'uq_qipai_payments_client_request', 'uq_qipai_payments_provider_id'
      ))
    OR (table_name = 'qipai_payment_callbacks'
      AND index_name = 'uq_qipai_payment_callback_provider')
    OR (table_name = 'qipai_payment_configs'
      AND index_name = 'idx_qipai_payment_config_resolution'))
GROUP BY table_name, index_name ORDER BY table_name, index_name;

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