-- Add parent_message_id column to messages table for reply functionality
ALTER TABLE messages ADD COLUMN IF NOT EXISTS `parent_message_id` INT NULL AFTER `attachments`;
ALTER TABLE messages ADD CONSTRAINT `fk_messages_parent` FOREIGN KEY (`parent_message_id`) REFERENCES `messages`(`id`) ON DELETE CASCADE;