-- dependson: None
-- model: api.models.message
-- description: alter ConversationUserStatus and Conversation
-- author: keyang@wanmeizhensuo.com
-- date: 2015.09.02 15:00:00

BEGIN;

ALTER TABLE `api_conversation` ADD COLUMN `last_msg_content_disp` longtext NOT NULL;
UPDATE `api_conversation` SET `last_msg_content_disp` = ;

ALTER TABLE `api_conversationuserstatus` ADD COLUMN `is_empty` bool DEFAULT 1 NOT NULL;
ALTER TABLE `api_conversationuserstatus` ALTER COLUMN `is_empty` DROP DEFAULT;
ALTER TABLE `api_conversationuserstatus` ADD COLUMN `last_reply_time` datetime(6) DEFAULT 2015-09-02 11:17:33 NOT NULL;
ALTER TABLE `api_conversationuserstatus` ALTER COLUMN `last_reply_time` DROP DEFAULT;
ALTER TABLE `api_conversationuserstatus` ADD COLUMN `read_status` bool DEFAULT 1 NOT NULL;
ALTER TABLE `api_conversationuserstatus` ALTER COLUMN `read_status` DROP DEFAULT;
CREATE INDEX `api_conversationuserstatus_conversation_list` ON `api_conversationuserstatus` (`user_id`, `is_empty`, `read_status`, `last_reply_time`);

CREATE INDEX `api_message_cvrst_msgs` ON `api_message` (`conversation_id`, `send_time`);
COMMIT;
