From ee17c2d0863d573df433e5aa4fb43a99a234aacc Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 14:12:38 +0000 Subject: [PATCH] Refactor: Remove unused JSON columns --- src/integrations/supabase/types.ts | 12 -------- ...3_6b17aac9-811a-486e-9228-000d95a63480.sql | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 supabase/migrations/20251003141223_6b17aac9-811a-486e-9228-000d95a63480.sql diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index 0fbb8cf6..c14cdddc 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -1347,7 +1347,6 @@ export type Database = { name: string ride_type: string slug: string - technical_specs: Json | null updated_at: string } Insert: { @@ -1363,7 +1362,6 @@ export type Database = { name: string ride_type: string slug: string - technical_specs?: Json | null updated_at?: string } Update: { @@ -1379,7 +1377,6 @@ export type Database = { name?: string ride_type?: string slug?: string - technical_specs?: Json | null updated_at?: string } Relationships: [ @@ -1651,14 +1648,12 @@ export type Database = { card_image_url: string | null category: string closing_date: string | null - coaster_stats: Json | null coaster_type: string | null created_at: string description: string | null designer_id: string | null drop_height_meters: number | null duration_seconds: number | null - former_names: Json | null height_requirement: number | null id: string image_url: string | null @@ -1678,7 +1673,6 @@ export type Database = { seating_type: string | null slug: string status: string - technical_specs: Json | null updated_at: string } Insert: { @@ -1691,14 +1685,12 @@ export type Database = { card_image_url?: string | null category: string closing_date?: string | null - coaster_stats?: Json | null coaster_type?: string | null created_at?: string description?: string | null designer_id?: string | null drop_height_meters?: number | null duration_seconds?: number | null - former_names?: Json | null height_requirement?: number | null id?: string image_url?: string | null @@ -1718,7 +1710,6 @@ export type Database = { seating_type?: string | null slug: string status?: string - technical_specs?: Json | null updated_at?: string } Update: { @@ -1731,14 +1722,12 @@ export type Database = { card_image_url?: string | null category?: string closing_date?: string | null - coaster_stats?: Json | null coaster_type?: string | null created_at?: string description?: string | null designer_id?: string | null drop_height_meters?: number | null duration_seconds?: number | null - former_names?: Json | null height_requirement?: number | null id?: string image_url?: string | null @@ -1758,7 +1747,6 @@ export type Database = { seating_type?: string | null slug?: string status?: string - technical_specs?: Json | null updated_at?: string } Relationships: [ diff --git a/supabase/migrations/20251003141223_6b17aac9-811a-486e-9228-000d95a63480.sql b/supabase/migrations/20251003141223_6b17aac9-811a-486e-9228-000d95a63480.sql new file mode 100644 index 00000000..2dbd3034 --- /dev/null +++ b/supabase/migrations/20251003141223_6b17aac9-811a-486e-9228-000d95a63480.sql @@ -0,0 +1,30 @@ +-- ═══════════════════════════════════════════════════════════════════ +-- 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'; \ No newline at end of file