wetalk/supabase/migrations/008_shows.sql
ordinarthur 828b3b09e9
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 37s
add many things 2
2026-04-13 15:52:26 +02:00

26 lines
735 B
SQL

-- Shows / Series
CREATE TABLE shows (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
creator_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
title text NOT NULL,
description text,
cover_url text,
created_at timestamptz NOT NULL DEFAULT now()
);
ALTER TABLE shows ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Anyone can view shows"
ON shows FOR SELECT
USING (true);
CREATE POLICY "Creators can manage their own shows"
ON shows FOR ALL
USING (creator_id = auth.uid())
WITH CHECK (creator_id = auth.uid());
-- Add show_id to podcasts
ALTER TABLE podcasts ADD COLUMN show_id uuid REFERENCES shows(id) ON DELETE SET NULL;
CREATE INDEX idx_podcasts_show ON podcasts(show_id) WHERE show_id IS NOT NULL;