From 95047030409cd2fb7cb53f37ffd3d1355e988f4c Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Wed, 29 Oct 2025 02:40:01 +0000 Subject: [PATCH] feat: Add Phase 9B indexes --- ...1_6b88c134-57a1-4d43-8c40-7487e7363042.sql | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 supabase/migrations/20251029023951_6b88c134-57a1-4d43-8c40-7487e7363042.sql diff --git a/supabase/migrations/20251029023951_6b88c134-57a1-4d43-8c40-7487e7363042.sql b/supabase/migrations/20251029023951_6b88c134-57a1-4d43-8c40-7487e7363042.sql new file mode 100644 index 00000000..b37542cf --- /dev/null +++ b/supabase/migrations/20251029023951_6b88c134-57a1-4d43-8c40-7487e7363042.sql @@ -0,0 +1,88 @@ +-- Phase 9B: Add Medium-Priority Foreign Key Indexes +-- These support less-frequent operations like historical data lookups and audit trails + +-- Historical data foreign keys (4 indexes) +CREATE INDEX IF NOT EXISTS idx_historical_parks_location_id + ON historical_parks(location_id); + +CREATE INDEX IF NOT EXISTS idx_historical_parks_successor_park_id + ON historical_parks(successor_park_id); + +CREATE INDEX IF NOT EXISTS idx_historical_rides_relocated_to_park_id + ON historical_rides(relocated_to_park_id); + +CREATE INDEX IF NOT EXISTS idx_historical_rides_successor_ride_id + ON historical_rides(successor_ride_id); + +-- Audit trail foreign keys (5 indexes) +CREATE INDEX IF NOT EXISTS idx_admin_settings_updated_by + ON admin_settings(updated_by); + +CREATE INDEX IF NOT EXISTS idx_profile_audit_log_changed_by + ON profile_audit_log(changed_by); + +CREATE INDEX IF NOT EXISTS idx_contact_submissions_resolved_by + ON contact_submissions(resolved_by); + +CREATE INDEX IF NOT EXISTS idx_contact_submissions_archived_by + ON contact_submissions(archived_by); + +CREATE INDEX IF NOT EXISTS idx_user_roles_granted_by + ON user_roles(granted_by); + +-- Submission tracking foreign keys (5 indexes) +CREATE INDEX IF NOT EXISTS idx_company_versions_submission_id + ON company_versions(submission_id); + +CREATE INDEX IF NOT EXISTS idx_ride_model_versions_submission_id + ON ride_model_versions(submission_id); + +CREATE INDEX IF NOT EXISTS idx_ride_model_versions_manufacturer_id + ON ride_model_versions(manufacturer_id); + +CREATE INDEX IF NOT EXISTS idx_ride_models_manufacturer_id + ON ride_models(manufacturer_id); + +CREATE INDEX IF NOT EXISTS idx_park_submissions_location_id + ON park_submissions(location_id); + +-- Location/timeline foreign keys (8 indexes) +CREATE INDEX IF NOT EXISTS idx_park_location_history_park_id + ON park_location_history(park_id); + +CREATE INDEX IF NOT EXISTS idx_park_location_history_old_location_id + ON park_location_history(old_location_id); + +CREATE INDEX IF NOT EXISTS idx_park_location_history_new_location_id + ON park_location_history(new_location_id); + +CREATE INDEX IF NOT EXISTS idx_park_operating_hours_park_id + ON park_operating_hours(park_id); + +CREATE INDEX IF NOT EXISTS idx_entity_timeline_events_from_location_id + ON entity_timeline_events(from_location_id); + +CREATE INDEX IF NOT EXISTS idx_entity_timeline_events_to_location_id + ON entity_timeline_events(to_location_id); + +CREATE INDEX IF NOT EXISTS idx_timeline_event_submissions_from_location_id + ON timeline_event_submissions(from_location_id); + +CREATE INDEX IF NOT EXISTS idx_timeline_event_submissions_to_location_id + ON timeline_event_submissions(to_location_id); + +-- Miscellaneous relationship foreign keys (6 indexes) +CREATE INDEX IF NOT EXISTS idx_contact_email_threads_sent_by + ON contact_email_threads(sent_by); + +CREATE INDEX IF NOT EXISTS idx_notification_logs_template_id + ON notification_logs(template_id); + +CREATE INDEX IF NOT EXISTS idx_review_deletions_park_id + ON review_deletions(park_id); + +CREATE INDEX IF NOT EXISTS idx_review_deletions_ride_id + ON review_deletions(ride_id); + +CREATE INDEX IF NOT EXISTS idx_user_blocks_blocked_id + ON user_blocks(blocked_id); \ No newline at end of file