From 0679aa6218e56710a7290770bcb94d0913d9721d Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Sat, 16 May 2026 00:47:44 +0200 Subject: [PATCH] fix(backend/realtime): add community_posts to supabase_realtime publication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The community feed's likes/dislikes/comments/reposts counters never live- updated for foreign actions because the table simply wasn't in the publication. useCommunityRealtime subscribed to UPDATE on community_posts, the channel opened cleanly, but no events ever arrived for that table — Supabase only broadcasts what's published. The notifications channel (rebreak.notifications, added in 20260511) was in the publication from day one, so users got the "X liked your post" banner correctly. That made the gap look like a frontend rendering bug all along; it was actually a missing one-line publication grant. After this migration deploys, the React-Query cache patcher in useCommunityRealtime will receive UPDATE events, patch the post in place, and PostCard will re-render with the correct displayedCount derived from post.likesCount + the (now-cleared) optimistic delta. --- .../migration.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 backend/prisma/migrations/20260516_enable_community_posts_realtime/migration.sql diff --git a/backend/prisma/migrations/20260516_enable_community_posts_realtime/migration.sql b/backend/prisma/migrations/20260516_enable_community_posts_realtime/migration.sql new file mode 100644 index 0000000..f6f7d70 --- /dev/null +++ b/backend/prisma/migrations/20260516_enable_community_posts_realtime/migration.sql @@ -0,0 +1,15 @@ +-- Enable Supabase Realtime for rebreak.community_posts. +-- +-- Why: foreign-like counts never updated in the feed because the table was +-- never in the supabase_realtime publication. useCommunityRealtime hooks +-- listen for UPDATE on community_posts (likes_count, dislikes_count, +-- comments_count, reposts_count) and patch the React-Query cache so visible +-- PostCards re-render with the new count. Without the publication entry the +-- whole channel is silent — users only ever saw the notifications channel +-- fire (rebreak.notifications was added in 20260511) and assumed realtime +-- was working end to end. It wasn't, for posts. +-- +-- After deploy, the count on a PostCard should reflect a foreign user's like +-- within ~200ms of the API write, without pull-to-refresh. + +ALTER PUBLICATION supabase_realtime ADD TABLE rebreak.community_posts;