initial commit: rocket.new export of broadcastbeat

This commit is contained in:
Ryan Salazar
2026-05-07 16:39:17 +00:00
commit 70aa1ad46e
302 changed files with 60710 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
-- User Follows Migration for BroadcastBeat
-- Adds follow/unfollow functionality between users
-- ============================================================
-- 1. USER FOLLOWS TABLE
-- ============================================================
CREATE TABLE IF NOT EXISTS public.user_follows (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
follower_id UUID NOT NULL REFERENCES public.user_profiles(id) ON DELETE CASCADE,
following_id UUID NOT NULL REFERENCES public.user_profiles(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT user_follows_no_self_follow CHECK (follower_id != following_id)
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_user_follows_unique
ON public.user_follows (follower_id, following_id);
CREATE INDEX IF NOT EXISTS idx_user_follows_follower_id
ON public.user_follows (follower_id);
CREATE INDEX IF NOT EXISTS idx_user_follows_following_id
ON public.user_follows (following_id);
-- ============================================================
-- 2. ENABLE RLS
-- ============================================================
ALTER TABLE public.user_follows ENABLE ROW LEVEL SECURITY;
-- ============================================================
-- 3. RLS POLICIES
-- ============================================================
DROP POLICY IF EXISTS "public_read_user_follows" ON public.user_follows;
CREATE POLICY "public_read_user_follows"
ON public.user_follows FOR SELECT TO public USING (true);
DROP POLICY IF EXISTS "users_manage_own_follows" ON public.user_follows;
CREATE POLICY "users_manage_own_follows"
ON public.user_follows FOR ALL TO authenticated
USING (follower_id = auth.uid())
WITH CHECK (follower_id = auth.uid());