
CREATE TABLE `was_private_message_draft` (
  `private_message_draft_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) unsigned NOT NULL,
  `to_user_id` int(11) unsigned DEFAULT NULL,
  `is_group` tinyint(1) NOT NULL DEFAULT '0',
  `subject` text,
  `message` text,
  `star` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `user_image_ids` text COMMENT 'comma separated list of user image ids',
  `pre_written_comment_ids` text DEFAULT NULL COMMENT 'comma separated list of pre-written comment ids',
  `tag` varchar(100) DEFAULT NULL COMMENT 'Admin tag',
  `insert_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `update_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`private_message_draft_id`),
  KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB COMMENT='Keeps track of users private message drafts';


CREATE TABLE `was_private_message_star` (
  `private_message_star_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) unsigned NOT NULL,
  `private_message_id` int(11) unsigned NOT NULL,
  `insert_timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`private_message_star_id`),
  UNIQUE KEY `idx_user_private_message` (`user_id`,`private_message_id`)
) ENGINE=InnoDB COMMENT='stores private messages which are marked as star';


ALTER TABLE `was_private_message_inbox` CHANGE `status` `status` ENUM('PENDING','VIEWED','DELETED','TRASH') CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'PENDING' COMMENT 'PENDING - User has an unread message within the thread, VIEWED - User has read all messages within the thread, DELETED - User has deleted entire message from trash, TRASH - messages moved to trash';

ALTER TABLE `was_private_message_outbox` CHANGE `status` `status` ENUM('VIEWED','DELETED','TRASH') CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;

ALTER TABLE `was_private_message_status` CHANGE `status` `status` ENUM('PENDING','VIEWED','DELETED','TRASH') CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'PENDING' COMMENT 'PENDING - User has not read message, VIEWED - User has read message, DELETED - User has deleted entire message from trash, TRASH - messages moved to trash';

ALTER TABLE `was_private_message_star` ADD KEY `idx_private_message_id` (`private_message_id`);