-- Read-only check: select the database used by private/BookingSystem/config.php
-- in phpMyAdmin, then run this in its SQL tab. No data is changed.
SELECT DATABASE() AS selected_database,
       'users table' AS requirement,
       IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='users'),'OK','MISSING') AS status
UNION ALL SELECT DATABASE(),'provinces table',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='provinces'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'units table',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='units'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'migration_history table',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='migration_history'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'units.deleted_at (migration 006)',IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='units' AND column_name='deleted_at'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'units.unit_type_id (migration 002)',IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='units' AND column_name='unit_type_id'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'administrator_sessions table',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='administrator_sessions'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'province_settings table',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='province_settings'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'platform_order_rank_settings table',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='platform_order_rank_settings'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'province_events table (migration 014)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='province_events'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'programme_table_plans table (migration 036)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='programme_table_plans'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'event_day_packs table (migration 037)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='event_day_packs'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'offline_checkin_batches table (migration 037)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='offline_checkin_batches'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'finance_ledger_entries table (migration 038)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='finance_ledger_entries'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'finance_bank_accounts table (migration 038)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='finance_bank_accounts'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'subscription_periods table (migration 039)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='subscription_periods'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'finance_expense_items table (migration 039)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='finance_expense_items'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'finance_year_end_snapshots table (migration 039)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='finance_year_end_snapshots'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'invoice_issuer_settings table (migration 040)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='invoice_issuer_settings'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'finance_invoice_lines table (migration 040)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='finance_invoice_lines'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'finance_credit_notes table (migration 040)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='finance_credit_notes'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'welfare_cases table (migration 041)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='welfare_cases'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'welfare_scope_settings table (migration 041)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='welfare_scope_settings'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'welfare_exceptional_access table (migration 041)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='welfare_exceptional_access'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'people.birth_date (migration 042)',IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='people' AND column_name='birth_date'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'report_catalogue table (migration 042)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='report_catalogue'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'report_runs table (migration 042)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='report_runs'),'OK','MISSING')
UNION ALL SELECT DATABASE(),'report_schedules table (migration 042)',IF(EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='report_schedules'),'OK','MISSING');
