-- depends_on: room_message
ALTER TABLE room_message ADD COLUMN IF NOT EXISTS system_type TEXT;
ALTER TABLE room_message ADD COLUMN IF NOT EXISTS metadata JSONB NOT NULL DEFAULT '{}';

COMMENT ON COLUMN room_message.system_type IS
  'System message type: user_joined, user_left, room_renamed, room_topic_changed, '
  'room_archived, message_pinned, dm_created, etc. NULL for regular user messages. '
  'Learned from Rocket.Chat MessageTypes system.';
COMMENT ON COLUMN room_message.metadata IS
  'Structured metadata for system messages (e.g. old_name, new_name for rename events).';
