wetalk/supabase/migrations/010_increment_plays.sql
ordinarthur 2fbccfac10
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 39s
add listen count
2026-04-13 16:14:50 +02:00

10 lines
250 B
PL/PgSQL

-- RPC to atomically increment plays_count
CREATE OR REPLACE FUNCTION increment_plays(podcast_id uuid)
RETURNS void AS $$
BEGIN
UPDATE podcasts
SET plays_count = plays_count + 1
WHERE id = podcast_id;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;