SELECT COUNT(*) = 4 AS api_pull_tables_ready FROM information_schema.tables WHERE table_schema = DATABASE() AND engine = 'InnoDB' AND table_name IN ('mdp_connector_api_pull_profile', 'mdp_connector_api_pull_run', 'mdp_connector_api_pull_page', 'mdp_connector_api_pull_rate'); SELECT COUNT(*) = 5 AS api_pull_unique_indexes_ready FROM ( SELECT table_name, index_name, GROUP_CONCAT(column_name ORDER BY seq_in_index) AS key_columns FROM information_schema.statistics WHERE table_schema = DATABASE() AND non_unique = 0 AND table_name IN ('mdp_connector_api_pull_profile', 'mdp_connector_api_pull_run', 'mdp_connector_api_pull_page', 'mdp_connector_api_pull_rate') GROUP BY table_name, index_name ) AS keys_found WHERE (table_name = 'mdp_connector_api_pull_profile' AND index_name = 'uk_api_pull_active' AND key_columns = 'tenant_id,factory_id,dataset_id,source_id,active_slot') OR (table_name = 'mdp_connector_api_pull_run' AND index_name = 'uk_api_pull_run_active' AND key_columns = 'tenant_id,factory_id,dataset_id,source_id,active_slot') OR (table_name = 'mdp_connector_api_pull_page' AND index_name = 'PRIMARY' AND key_columns = 'run_id,ordinal') OR (table_name = 'mdp_connector_api_pull_page' AND index_name = 'uk_api_pull_position' AND key_columns = 'run_id,position_sha256') OR (table_name = 'mdp_connector_api_pull_rate' AND index_name = 'PRIMARY' AND key_columns = 'tenant_id,source_id'); SELECT COUNT(*) = 6 AS api_pull_replay_columns_ready FROM information_schema.columns WHERE table_schema = DATABASE() AND ((table_name = 'mdp_connector_api_pull_page' AND ((column_name = 'response_body' AND data_type = 'mediumblob' AND is_nullable = 'YES') OR (column_name = 'response_sha256' AND character_maximum_length = 64 AND collation_name = 'ascii_bin') OR (column_name = 'raw_batch_id' AND character_maximum_length = 36 AND is_nullable = 'YES'))) OR (table_name = 'mdp_connector_api_pull_run' AND ((column_name = 'position_json' AND data_type = 'json' AND is_nullable = 'NO') OR (column_name = 'confirmed_until' AND data_type = 'datetime' AND datetime_precision = 6) OR (column_name = 'retry_at' AND data_type = 'datetime' AND datetime_precision = 6)))); SELECT IF(COUNT(*)=2,1,0) AS capture_and_recovery_innodb FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND ENGINE='InnoDB' AND TABLE_NAME IN ('mdp_connector_api_pull_capture','mdp_connector_api_pull_recovery'); SELECT IF(COUNT(*)=4,1,0) AS capture_order_and_unique_raw FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='mdp_connector_api_pull_capture' AND NON_UNIQUE=0 AND ((INDEX_NAME='PRIMARY' AND ((SEQ_IN_INDEX=1 AND COLUMN_NAME='run_id') OR (SEQ_IN_INDEX=2 AND COLUMN_NAME='ordinal') OR (SEQ_IN_INDEX=3 AND COLUMN_NAME='attempt'))) OR (INDEX_NAME='uk_api_pull_capture_batch' AND SEQ_IN_INDEX=1 AND COLUMN_NAME='batch_id')); SELECT IF(COUNT(*)=3,1,0) AS recovery_history_order FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='mdp_connector_api_pull_recovery' AND INDEX_NAME='ix_api_pull_recovery_page' AND ((SEQ_IN_INDEX=1 AND COLUMN_NAME='run_id') OR (SEQ_IN_INDEX=2 AND COLUMN_NAME='ordinal') OR (SEQ_IN_INDEX=3 AND COLUMN_NAME='id')); SELECT IF(COUNT(*)=3,1,0) AS raw_reference_collation FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLLATION_NAME='ascii_bin' AND ((TABLE_NAME IN ('mdp_connector_api_pull_capture','mdp_ingest_raw_batch') AND COLUMN_NAME='batch_id') OR (TABLE_NAME='mdp_connector_api_pull_recovery' AND COLUMN_NAME='prior_batch_id'));