ALTER TABLE `messages` ADD COLUMN `is_starred` boolean DEFAULT false NOT NULL;
CREATE INDEX `messages_receiver_starred_idx` ON `messages`(`receiver_id`, `is_starred`);

CREATE TABLE `message_drafts` (
	`id` varchar(128) PRIMARY KEY NOT NULL,
	`user_id` varchar(128) NOT NULL,
	`receiver_id` varchar(128),
	`subject` varchar(255),
	`content` text,
	`parent_message_id` varchar(128),
	`updated_at` timestamp DEFAULT (now()) ON UPDATE now() NOT NULL,
	`created_at` timestamp DEFAULT (now()) NOT NULL,
	CONSTRAINT `message_drafts_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action,
	CONSTRAINT `message_drafts_receiver_id_users_id_fk` FOREIGN KEY (`receiver_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action
);
CREATE INDEX `message_drafts_user_idx` ON `message_drafts`(`user_id`);
CREATE INDEX `message_drafts_user_updated_idx` ON `message_drafts`(`user_id`, `updated_at`);
