diff --git a/src/types/database.ts b/src/types/database.ts index ed8a47a5..557e74ea 100644 --- a/src/types/database.ts +++ b/src/types/database.ts @@ -112,7 +112,7 @@ export interface RideModel { category: 'roller_coaster' | 'flat_ride' | 'water_ride' | 'dark_ride' | 'kiddie_ride' | 'transportation'; ride_type: string; description?: string; - technical_specs?: any; // Legacy JSON field + technical_specs?: any; // ⚠️ DEPRECATED - Use ride_model_technical_specifications table instead technical_specifications?: RideModelTechnicalSpec[]; // New relational data } @@ -138,9 +138,9 @@ export interface Ride { max_height_meters?: number; length_meters?: number; inversions?: number; - coaster_stats?: any; // Legacy JSON field - technical_specs?: any; // Legacy JSON field - former_names?: any; // Legacy JSON field + coaster_stats?: any; // ⚠️ DEPRECATED - Use ride_coaster_statistics table instead + technical_specs?: any; // ⚠️ DEPRECATED - Use ride_technical_specifications table instead + former_names?: any; // ⚠️ DEPRECATED - Use ride_name_history table instead // New relational data technical_specifications?: RideTechnicalSpec[]; coaster_statistics?: RideCoasterStat[]; diff --git a/supabase/migrations/20251002192802_fd7c5b11-83f0-4658-8cdd-2fe57ff3f084.sql b/supabase/migrations/20251002192802_fd7c5b11-83f0-4658-8cdd-2fe57ff3f084.sql new file mode 100644 index 00000000..e098f4dd --- /dev/null +++ b/supabase/migrations/20251002192802_fd7c5b11-83f0-4658-8cdd-2fe57ff3f084.sql @@ -0,0 +1,23 @@ +-- Deprecate legacy JSON columns in rides table +-- These columns violate the architectural rule: "NEVER STORE JSON IN SQL COLUMNS" +-- Use relational tables instead: +-- - ride_technical_specifications (for technical_specs) +-- - ride_coaster_statistics (for coaster_stats) +-- - ride_name_history (for former_names) + +-- Mark columns as deprecated with comments +COMMENT ON COLUMN public.rides.technical_specs IS '⚠️ DEPRECATED: Use ride_technical_specifications table instead. This JSON column violates data normalization principles and should not be used for new data.'; +COMMENT ON COLUMN public.rides.coaster_stats IS '⚠️ DEPRECATED: Use ride_coaster_statistics table instead. This JSON column violates data normalization principles and should not be used for new data.'; +COMMENT ON COLUMN public.rides.former_names IS '⚠️ DEPRECATED: Use ride_name_history table instead. This JSON column violates data normalization principles and should not be used for new data.'; + +-- Set default to NULL to prevent accidental usage +ALTER TABLE public.rides + ALTER COLUMN technical_specs SET DEFAULT NULL, + ALTER COLUMN coaster_stats SET DEFAULT NULL, + ALTER COLUMN former_names SET DEFAULT NULL; + +-- Same for ride_models table +COMMENT ON COLUMN public.ride_models.technical_specs IS '⚠️ DEPRECATED: Use ride_model_technical_specifications table instead. This JSON column violates data normalization principles and should not be used for new data.'; + +ALTER TABLE public.ride_models + ALTER COLUMN technical_specs SET DEFAULT NULL; \ No newline at end of file