Files
thrilltrack-explorer/supabase/migrations/20251003141223_6b17aac9-811a-486e-9228-000d95a63480.sql
2025-10-03 14:12:38 +00:00

30 lines
2.0 KiB
SQL

-- ═══════════════════════════════════════════════════════════════════
-- MIGRATION: Remove JSON Columns from Rides and Ride Models
-- ═══════════════════════════════════════════════════════════════════
--
-- This migration enforces the "NEVER STORE JSON IN SQL COLUMNS" rule
-- by removing deprecated JSON columns that have been replaced with
-- proper relational tables:
--
-- rides.former_names → ride_name_history table
-- rides.coaster_stats → ride_coaster_statistics table
-- rides.technical_specs → ride_technical_specifications table
-- ride_models.technical_specs → ride_model_technical_specifications table
--
-- ═══════════════════════════════════════════════════════════════════
-- Drop deprecated JSON columns from rides table
ALTER TABLE rides
DROP COLUMN IF EXISTS former_names,
DROP COLUMN IF EXISTS coaster_stats,
DROP COLUMN IF EXISTS technical_specs;
-- Drop deprecated JSON column from ride_models table
ALTER TABLE ride_models
DROP COLUMN IF EXISTS technical_specs;
-- Add comments to document the relational approach
COMMENT ON TABLE ride_name_history IS 'Stores historical names for rides - replaces rides.former_names JSON column';
COMMENT ON TABLE ride_coaster_statistics IS 'Stores coaster statistics for rides - replaces rides.coaster_stats JSON column';
COMMENT ON TABLE ride_technical_specifications IS 'Stores technical specifications for rides - replaces rides.technical_specs JSON column';
COMMENT ON TABLE ride_model_technical_specifications IS 'Stores technical specifications for ride models - replaces ride_models.technical_specs JSON column';