-- 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' ) );