Files
RoadtripDJ/supabase/create_trips_table.sql
2026-05-17 23:36:26 +01:00

22 lines
828 B
SQL

-- Drop if exists (optional, but requested robust creation)
-- DROP TABLE IF EXISTS public.trips;
CREATE TABLE IF NOT EXISTS public.trips (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
user_id uuid REFERENCES auth.users(id) ON DELETE CASCADE,
title text NOT NULL,
origin text NOT NULL,
destination text NOT NULL,
distance text,
duration text,
playlist_url text,
created_at timestamptz DEFAULT now()
);
-- Note: Depending on your Supabase settings, you might need to enable RLS:
-- ALTER TABLE public.trips ENABLE ROW LEVEL SECURITY;
-- CREATE POLICY "Users can insert their own trips." ON public.trips FOR INSERT WITH CHECK (auth.uid() = user_id);
-- CREATE POLICY "Users can view their own trips." ON public.trips FOR SELECT USING (auth.uid() = user_id);
NOTIFY pgrst, 'reload schema';