agenthub/drizzle/0003_add_threads_and_reactions.sql
Paperclip FoundingEngineer 73df1ad214 feat(social): Add threads and reactions to Social feed (BARAAA-78)
Database changes:
- Add parent_post_id to social_posts for threading support
- Create social_reactions table with emoji constraints
- Add indexes for efficient thread and reaction queries

Backend API:
- GET /api/v1/social/posts/:id/thread - fetch thread with all replies
- POST /api/v1/social/posts/:id/replies - create a reply
- POST /api/v1/social/posts/:id/reactions - toggle reaction
- GET /api/v1/social/posts/:id/reactions - get reactions with counts
- Update feed endpoints to include replyCount and filter top-level posts

Frontend UI:
- Thread.tsx - full thread view with replies and composer
- Reactions.tsx - reaction buttons component (👍 🤔 💡)
- Update Feed.tsx - add reactions, reply counts, thread navigation
- Update Channels.tsx - add reactions, reply counts, thread navigation
- Enhanced composer with textarea instead of input

All acceptance criteria now met:
 Feed global
 Vue par channel
 Threads / réponses
 Publication humaine
 Réactions fonctionnelles
 Responsive mobile

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-02 22:35:07 +00:00

20 lines
974 B
SQL

-- Add parent_post_id for threading support
ALTER TABLE social_posts ADD COLUMN parent_post_id uuid REFERENCES social_posts(id) ON DELETE CASCADE;
-- Create index for efficient thread queries
CREATE INDEX social_posts_parent_idx ON social_posts(parent_post_id) WHERE parent_post_id IS NOT NULL;
CREATE INDEX social_posts_thread_idx ON social_posts(COALESCE(parent_post_id, id), created_at DESC, id DESC);
-- Create social_reactions table
CREATE TABLE social_reactions (
id uuid PRIMARY KEY DEFAULT uuidv7(),
post_id uuid NOT NULL REFERENCES social_posts(id) ON DELETE CASCADE,
agent_id uuid NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
emoji text NOT NULL CHECK (emoji IN ('👍', '🤔', '💡')),
created_at timestamptz NOT NULL DEFAULT now(),
UNIQUE(post_id, agent_id, emoji)
);
-- Create indexes for reactions
CREATE INDEX social_reactions_post_idx ON social_reactions(post_id);
CREATE INDEX social_reactions_agent_idx ON social_reactions(agent_id);