Fix ride versioning synchronization

This commit is contained in:
gpt-engineer-app[bot]
2025-10-30 13:51:33 +00:00
parent 2efc4885a7
commit 6d6ec11e8b
2 changed files with 121 additions and 3 deletions

View File

@@ -2587,6 +2587,44 @@ export type Database = {
}, },
] ]
} }
ride_former_names: {
Row: {
created_at: string | null
id: string
name: string
ride_id: string
updated_at: string | null
used_from: string | null
used_until: string | null
}
Insert: {
created_at?: string | null
id?: string
name: string
ride_id: string
updated_at?: string | null
used_from?: string | null
used_until?: string | null
}
Update: {
created_at?: string | null
id?: string
name?: string
ride_id?: string
updated_at?: string | null
used_from?: string | null
used_until?: string | null
}
Relationships: [
{
foreignKeyName: "ride_former_names_ride_id_fkey"
columns: ["ride_id"]
isOneToOne: false
referencedRelation: "rides"
referencedColumns: ["id"]
},
]
}
ride_kiddie_details: { ride_kiddie_details: {
Row: { Row: {
character_theme: string | null character_theme: string | null
@@ -3280,6 +3318,7 @@ export type Database = {
} }
ride_versions: { ride_versions: {
Row: { Row: {
age_requirement: number | null
angle_degrees: number | null angle_degrees: number | null
animatronics_count: number | null animatronics_count: number | null
arm_length_meters: number | null arm_length_meters: number | null
@@ -3295,6 +3334,7 @@ export type Database = {
character_theme: string | null character_theme: string | null
closing_date: string | null closing_date: string | null
closing_date_precision: string | null closing_date_precision: string | null
coaster_type: string | null
created_at: string created_at: string
created_by: string | null created_by: string | null
description: string | null description: string | null
@@ -3303,10 +3343,11 @@ export type Database = {
duration_seconds: number | null duration_seconds: number | null
educational_theme: string | null educational_theme: string | null
flume_type: string | null flume_type: string | null
former_names: Json | null
gforce_max: number | null gforce_max: number | null
height_meters: number | null height_meters: number | null
height_requirement_cm: number | null height_requirement_cm: number | null
image_url: string | null
intensity_level: string | null
inversions_count: number | null inversions_count: number | null
is_current: boolean is_current: boolean
length_meters: number | null length_meters: number | null
@@ -3325,12 +3366,14 @@ export type Database = {
propulsion_method: string[] | null propulsion_method: string[] | null
ride_id: string ride_id: string
ride_model_id: string | null ride_model_id: string | null
ride_sub_type: string | null
ride_system: string | null ride_system: string | null
rotation_speed_rpm: number | null rotation_speed_rpm: number | null
rotation_type: string | null rotation_type: string | null
round_trip_duration_seconds: number | null round_trip_duration_seconds: number | null
route_length_meters: number | null route_length_meters: number | null
scenes_count: number | null scenes_count: number | null
seating_type: string | null
show_duration_seconds: number | null show_duration_seconds: number | null
slug: string slug: string
splash_height_meters: number | null splash_height_meters: number | null
@@ -3351,6 +3394,7 @@ export type Database = {
wetness_level: string | null wetness_level: string | null
} }
Insert: { Insert: {
age_requirement?: number | null
angle_degrees?: number | null angle_degrees?: number | null
animatronics_count?: number | null animatronics_count?: number | null
arm_length_meters?: number | null arm_length_meters?: number | null
@@ -3366,6 +3410,7 @@ export type Database = {
character_theme?: string | null character_theme?: string | null
closing_date?: string | null closing_date?: string | null
closing_date_precision?: string | null closing_date_precision?: string | null
coaster_type?: string | null
created_at?: string created_at?: string
created_by?: string | null created_by?: string | null
description?: string | null description?: string | null
@@ -3374,10 +3419,11 @@ export type Database = {
duration_seconds?: number | null duration_seconds?: number | null
educational_theme?: string | null educational_theme?: string | null
flume_type?: string | null flume_type?: string | null
former_names?: Json | null
gforce_max?: number | null gforce_max?: number | null
height_meters?: number | null height_meters?: number | null
height_requirement_cm?: number | null height_requirement_cm?: number | null
image_url?: string | null
intensity_level?: string | null
inversions_count?: number | null inversions_count?: number | null
is_current?: boolean is_current?: boolean
length_meters?: number | null length_meters?: number | null
@@ -3396,12 +3442,14 @@ export type Database = {
propulsion_method?: string[] | null propulsion_method?: string[] | null
ride_id: string ride_id: string
ride_model_id?: string | null ride_model_id?: string | null
ride_sub_type?: string | null
ride_system?: string | null ride_system?: string | null
rotation_speed_rpm?: number | null rotation_speed_rpm?: number | null
rotation_type?: string | null rotation_type?: string | null
round_trip_duration_seconds?: number | null round_trip_duration_seconds?: number | null
route_length_meters?: number | null route_length_meters?: number | null
scenes_count?: number | null scenes_count?: number | null
seating_type?: string | null
show_duration_seconds?: number | null show_duration_seconds?: number | null
slug: string slug: string
splash_height_meters?: number | null splash_height_meters?: number | null
@@ -3422,6 +3470,7 @@ export type Database = {
wetness_level?: string | null wetness_level?: string | null
} }
Update: { Update: {
age_requirement?: number | null
angle_degrees?: number | null angle_degrees?: number | null
animatronics_count?: number | null animatronics_count?: number | null
arm_length_meters?: number | null arm_length_meters?: number | null
@@ -3437,6 +3486,7 @@ export type Database = {
character_theme?: string | null character_theme?: string | null
closing_date?: string | null closing_date?: string | null
closing_date_precision?: string | null closing_date_precision?: string | null
coaster_type?: string | null
created_at?: string created_at?: string
created_by?: string | null created_by?: string | null
description?: string | null description?: string | null
@@ -3445,10 +3495,11 @@ export type Database = {
duration_seconds?: number | null duration_seconds?: number | null
educational_theme?: string | null educational_theme?: string | null
flume_type?: string | null flume_type?: string | null
former_names?: Json | null
gforce_max?: number | null gforce_max?: number | null
height_meters?: number | null height_meters?: number | null
height_requirement_cm?: number | null height_requirement_cm?: number | null
image_url?: string | null
intensity_level?: string | null
inversions_count?: number | null inversions_count?: number | null
is_current?: boolean is_current?: boolean
length_meters?: number | null length_meters?: number | null
@@ -3467,12 +3518,14 @@ export type Database = {
propulsion_method?: string[] | null propulsion_method?: string[] | null
ride_id?: string ride_id?: string
ride_model_id?: string | null ride_model_id?: string | null
ride_sub_type?: string | null
ride_system?: string | null ride_system?: string | null
rotation_speed_rpm?: number | null rotation_speed_rpm?: number | null
rotation_type?: string | null rotation_type?: string | null
round_trip_duration_seconds?: number | null round_trip_duration_seconds?: number | null
route_length_meters?: number | null route_length_meters?: number | null
scenes_count?: number | null scenes_count?: number | null
seating_type?: string | null
show_duration_seconds?: number | null show_duration_seconds?: number | null
slug?: string slug?: string
splash_height_meters?: number | null splash_height_meters?: number | null

View File

@@ -0,0 +1,65 @@
-- ============================================================================
-- COMPREHENSIVE VERSIONING FIX: Add missing fields to ride_versions
-- ============================================================================
-- Add missing columns from rides table to ride_versions
ALTER TABLE public.ride_versions
ADD COLUMN IF NOT EXISTS ride_sub_type TEXT,
ADD COLUMN IF NOT EXISTS age_requirement INTEGER,
ADD COLUMN IF NOT EXISTS coaster_type TEXT,
ADD COLUMN IF NOT EXISTS seating_type TEXT,
ADD COLUMN IF NOT EXISTS intensity_level TEXT,
ADD COLUMN IF NOT EXISTS image_url TEXT;
-- Add comments for new columns
COMMENT ON COLUMN public.ride_versions.ride_sub_type IS 'Subtype classification within the main category';
COMMENT ON COLUMN public.ride_versions.age_requirement IS 'Minimum age requirement in years';
COMMENT ON COLUMN public.ride_versions.coaster_type IS 'Type of roller coaster (e.g., wooden, steel, hybrid)';
COMMENT ON COLUMN public.ride_versions.seating_type IS 'Type of seating configuration';
COMMENT ON COLUMN public.ride_versions.intensity_level IS 'Intensity level rating (e.g., mild, moderate, extreme)';
COMMENT ON COLUMN public.ride_versions.image_url IS 'Primary image URL for the ride';
-- ============================================================================
-- Create ride_former_names relational table (replacing JSONB)
-- ============================================================================
CREATE TABLE IF NOT EXISTS public.ride_former_names (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
ride_id UUID NOT NULL REFERENCES public.rides(id) ON DELETE CASCADE,
name TEXT NOT NULL,
used_from DATE,
used_until DATE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT now(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT now()
);
-- Add indexes for performance
CREATE INDEX IF NOT EXISTS idx_ride_former_names_ride_id ON public.ride_former_names(ride_id);
CREATE INDEX IF NOT EXISTS idx_ride_former_names_dates ON public.ride_former_names(used_from, used_until);
-- Enable RLS
ALTER TABLE public.ride_former_names ENABLE ROW LEVEL SECURITY;
-- Create RLS policies
CREATE POLICY "Public can view former names"
ON public.ride_former_names
FOR SELECT
USING (true);
CREATE POLICY "Moderators can manage former names"
ON public.ride_former_names
FOR ALL
USING (is_moderator(auth.uid()) AND has_aal2());
-- Add comments
COMMENT ON TABLE public.ride_former_names IS 'Historical names for rides - relational replacement for JSONB former_names';
COMMENT ON COLUMN public.ride_former_names.name IS 'Former name of the ride';
COMMENT ON COLUMN public.ride_former_names.used_from IS 'Date when this name started being used';
COMMENT ON COLUMN public.ride_former_names.used_until IS 'Date when this name stopped being used';
-- ============================================================================
-- Remove former_names JSONB column from ride_versions (violates no-JSONB rule)
-- ============================================================================
ALTER TABLE public.ride_versions DROP COLUMN IF EXISTS former_names;