
-- WA Main Database: Create table for storing users chat setting
CREATE TABLE `was_chat_user_setting` (
  `chat_user_setting_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) unsigned NOT NULL,
  `all_message_sound` tinyint(1) unsigned NOT NULL,
  `mentioned_message_sound` tinyint(1) unsigned NOT NULL,
  `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 (`chat_user_setting_id`),
  KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB COMMENT='Keeps track of users chat settings';

CREATE TRIGGER `was_chat_user_setting_insert_timestamp` BEFORE INSERT ON `was_chat_user_setting`
FOR EACH ROW SET NEW.insert_timestamp = NOW();
