diff --git a/supabase/migrations/20250920124021_a1394ba6-ac0b-4188-ab2b-51e716d07824.sql b/supabase/migrations/20250920124021_a1394ba6-ac0b-4188-ab2b-51e716d07824.sql new file mode 100644 index 00000000..10c9acfc --- /dev/null +++ b/supabase/migrations/20250920124021_a1394ba6-ac0b-4188-ab2b-51e716d07824.sql @@ -0,0 +1,16 @@ +-- Add person_type field to companies table to distinguish between companies, individuals, and firms +ALTER TABLE public.companies +ADD COLUMN IF NOT EXISTS person_type TEXT DEFAULT 'company' CHECK (person_type IN ('company', 'individual', 'firm', 'organization')); + +-- Add index for better performance on company person_type queries +CREATE INDEX IF NOT EXISTS idx_companies_person_type ON public.companies(person_type); + +-- Add index for ride sub-type if it doesn't exist +CREATE INDEX IF NOT EXISTS idx_rides_ride_sub_type ON public.rides(ride_sub_type); + +-- Add comments for documentation +COMMENT ON COLUMN public.rides.ride_sub_type IS 'Sub-category of ride type, e.g., "Flying Coaster", "Inverted Coaster", "Log Flume", "Shoot the Chutes"'; +COMMENT ON COLUMN public.companies.person_type IS 'Type of entity: company, individual, firm, or organization'; + +-- Update existing companies to have proper person_type (defaulting to company) +UPDATE public.companies SET person_type = 'company' WHERE person_type IS NULL; \ No newline at end of file