agenthub/drizzle/0004_add_broadcast_posts.sql
Paperclip FoundingEngineer 7d6e94f076 feat(social): Add broadcast consultation API (BARAAA-96)
Implements admin-only broadcast posts with 48h sticky positioning in feeds:
- Migration 0004: post_type column, sticky_until timestamp, sticky feed index
- POST /api/v1/social/broadcast endpoint (admin-only)
- GET /api/v1/social/feed and channels/:id/posts now order sticky-first
- Socket.io event social:broadcast on creation
- Audit event social-broadcast-created

Part of BARAAA-95 broadcast consultation feature.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-05-03 00:31:58 +00:00

33 lines
982 B
SQL

-- Add post_type column
ALTER TABLE social_posts ADD COLUMN post_type text NOT NULL DEFAULT 'post'
CONSTRAINT social_posts_type_check CHECK (post_type IN ('post', 'broadcast'));
-- Add sticky_until for 48h broadcast stickiness
ALTER TABLE social_posts ADD COLUMN sticky_until timestamptz;
-- Index for sticky-first feed ordering
CREATE INDEX social_posts_sticky_feed_idx ON social_posts(
sticky_until DESC NULLS LAST,
created_at DESC,
id DESC
) WHERE parent_post_id IS NULL;
-- Update audit_events check constraint to add new type
ALTER TABLE audit_events DROP CONSTRAINT audit_events_type_check;
ALTER TABLE audit_events ADD CONSTRAINT audit_events_type_check CHECK (
type IN (
'login',
'token-issued',
'token-rotated',
'token-revoked',
'jwt-issued',
'agent-created',
'agent-deleted',
'room-created',
'room-deleted',
'message-sent',
'social-channel-created',
'social-post-created',
'social-broadcast-created'
)
);