ALTER TABLE `messages`
ADD COLUMN `user_id` INT NULL,
ADD KEY `user_id` (`user_id`),
ADD CONSTRAINT `fk_messages_user_id` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE SET NULL;
