-- P2-6: 快捷回复模板
CREATE TABLE `message_templates` (
	`id` varchar(128) PRIMARY KEY NOT NULL,
	`user_id` varchar(128) NOT NULL,
	`title` varchar(100) NOT NULL,
	`content` text NOT NULL,
	`sort_order` integer DEFAULT 0 NOT NULL,
	`updated_at` timestamp DEFAULT (now()) ON UPDATE now() NOT NULL,
	`created_at` timestamp DEFAULT (now()) NOT NULL,
	CONSTRAINT `message_templates_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action
);
CREATE INDEX `message_templates_user_idx` ON `message_templates`(`user_id`);
CREATE INDEX `message_templates_user_sort_idx` ON `message_templates`(`user_id`, `sort_order`);
