Build a complete table, index, trigger and policy.
Multistep capstone — write ONE script that does all of the following, in order:
1. CREATE TABLE posts with: id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL, title TEXT NOT NULL, body TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT now().
2. CREATE INDEX idx_posts_user_id ON posts(user_id).
3. ALTER TABLE posts ENABLE ROW LEVEL SECURITY.
4. CREATE POLICY "Users read own posts" ON posts FOR SELECT USING (auth.uid() = user_id).
5. CREATE POLICY "Users insert own posts" ON posts FOR INSERT WITH CHECK (auth.uid() = user_id).
This is the production-ready pattern used in Supabase apps every day.
Sign in to save your code and track progress across devices.