ALTER TABLE chat_messages
    ADD COLUMN IF NOT EXISTS reply_to_message_id BIGINT REFERENCES chat_messages (id) ON DELETE SET NULL;

CREATE INDEX IF NOT EXISTS idx_chat_messages_reply_to ON chat_messages (reply_to_message_id);
