CREATE INDEX IF NOT EXISTS idx_messages_channel_created
  ON messages (channel_id, created_at);
--;;
CREATE INDEX IF NOT EXISTS idx_messages_parent
  ON messages (parent_id)
  WHERE parent_id IS NOT NULL;
--;;
CREATE INDEX IF NOT EXISTS idx_messages_search
  ON messages
  USING GIN (to_tsvector('english', body_md));
--;;
CREATE INDEX IF NOT EXISTS idx_notifications_user_unread
  ON notifications (user_id, created_at)
  WHERE read = false;
--;;
CREATE INDEX IF NOT EXISTS idx_channel_members_user
  ON channel_members (user_id);
--;;
CREATE INDEX IF NOT EXISTS idx_community_members_user
  ON community_members (user_id);
