SELECT table_name
FROM information_schema.tables
WHERE table_schema = DATABASE()
  AND table_name IN (
    'qipai_cleaning_settlement_events',
    'qipai_cleaning_settlement_reversals'
  )
ORDER BY table_name;

SELECT table_name, column_name, generation_expression
FROM information_schema.columns
WHERE table_schema = DATABASE()
  AND ((table_name = 'qipai_cleaning_settlement_items'
        AND column_name IN ('reversal_id', 'reversed_at', 'active_share_key'))
    OR (table_name = 'qipai_cleaning_settlements'
        AND column_name IN (
          'cancelled_by', 'cancelled_at', 'payout_request_no', 'payout_request_key'
        ))
    OR (table_name = 'qipai_cleaning_settlement_events'
        AND column_name = 'actor_type'))
ORDER BY table_name, column_name;

SELECT table_name, index_name
FROM information_schema.statistics
WHERE table_schema = DATABASE()
  AND ((table_name = 'qipai_cleaning_settlement_items'
        AND index_name = 'uq_qipai_cleaning_settlement_active_share')
    OR (table_name = 'qipai_cleaning_settlement_events'
        AND index_name = 'uq_qipai_cleaning_settlement_event_trace')
    OR (table_name = 'qipai_cleaning_settlement_reversals'
        AND index_name = 'uq_qipai_cleaning_settlement_reversal_parent')
    OR (table_name = 'qipai_cleaning_settlements'
        AND index_name = 'uq_qipai_cleaning_settlement_payout_request'))
GROUP BY table_name, index_name
ORDER BY table_name, index_name;

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