CREATE TABLE IF NOT EXISTS `tms_dynamicform_fields_##QID##` (
	`field_id` INT(10) NOT NULL AUTO_INCREMENT,
	`field_name` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`field_description` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`data_type` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`max_line` SMALLINT(5) NULL DEFAULT NULL,
	`width` SMALLINT(5) NULL DEFAULT NULL,
	`field_length` SMALLINT(5) NULL DEFAULT NULL,
	`decimal_length` SMALLINT(5) NULL DEFAULT NULL,
	`field_type` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`values_from_db` TINYINT(1) NULL DEFAULT '0',
	`unique_field` TINYINT(1) NULL DEFAULT '0',
	`allow_null` TINYINT(1) NULL DEFAULT '0',
	`primary_field` TINYINT(1) NULL DEFAULT '0',
	`primary_phone_no` TINYINT(1) NULL DEFAULT '0',
	`filter` TINYINT(1) NULL DEFAULT '0',
	`excel_export` TINYINT(1) NULL DEFAULT '0',
	`print_pdf` TINYINT(3) NOT NULL DEFAULT '0',
	`list_column` TINYINT(1) NULL DEFAULT '0',
	`required` TINYINT(1) NULL DEFAULT '0',
	`field_values` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`db_val_column` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`db_txt_column` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`onchange` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`onkeypress` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`onclick` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`status` TINYINT(1) NULL DEFAULT '1',
	`created_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
	`created_by` INT(10) NOT NULL,
	`modified_date` DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
	`modified_by` INT(10) NULL DEFAULT NULL,
	PRIMARY KEY (`field_id`) USING BTREE
) COLLATE = 'latin1_swedish_ci' ENGINE = InnoDB;

CREATE TABLE `tms_queue_template_##QID##` (
	`template_id` INT(11) NOT NULL AUTO_INCREMENT,
	`template` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`customer_email_subject` TEXT NULL COLLATE 'latin1_swedish_ci',
	`user_email_subject` TEXT NULL COLLATE 'latin1_swedish_ci',
	`customer_email_template` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`user_email_template` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`customer_sms_template` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`customer_wp_template` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`user_sms_template` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`user_wp_template` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`status` INT(11) NULL DEFAULT NULL,
	PRIMARY KEY (`template_id`) USING BTREE
) COLLATE = 'latin1_swedish_ci' ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `tms_queue_category_##QID##` (
	`category_id` INT(10) NOT NULL AUTO_INCREMENT,
	`category_name` VARCHAR(100) NOT NULL DEFAULT '0' COLLATE 'latin1_swedish_ci',
	`status` TINYINT(4) NULL DEFAULT '1',
	`default` TINYINT(4) NULL DEFAULT '0',
	PRIMARY KEY (`category_id`) USING BTREE
) COLLATE = 'latin1_swedish_ci' ENGINE = InnoDB;

CREATE TABLE `tms_queue_sub_category_##QID##` (
	`sub_category_id` INT(10) NOT NULL AUTO_INCREMENT,
	`category_id` INT(10) NOT NULL,
	`sub_category_name` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`message` TEXT NOT NULL COLLATE 'latin1_swedish_ci',
	`default` TINYINT(1) NULL DEFAULT '0',
	`priority_id` INT(11) NULL DEFAULT NULL,
	PRIMARY KEY (`sub_category_id`) USING BTREE,
	CONSTRAINT `FK_tms_queue_sub_category_##QID##_tms_queue_category_##QID##` FOREIGN KEY (`category_id`) REFERENCES `tms_queue_category_##QID##` (`category_id`) ON UPDATE NO ACTION ON DELETE RESTRICT
) COLLATE = 'latin1_swedish_ci' ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `tms_queue_priority_##QID##` (
	`priority_id` INT(11) NOT NULL AUTO_INCREMENT,
	`priority_name` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`colour_code` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`tat` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',	
	`order_no` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`is_default` TINYINT(4) NULL DEFAULT '0',
	`tat_time_min` VARCHAR(50) NULL DEFAULT '0' COLLATE 'latin1_swedish_ci',
	PRIMARY KEY (`priority_id`) USING BTREE
) COLLATE = 'latin1_swedish_ci' ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `tms_queue_status_##QID##` (
	`status_id` INT(11) NOT NULL AUTO_INCREMENT,
	`status_name` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`colour_code` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`ticket_status_type` INT(11) NULL DEFAULT NULL,
	`order_no` INT(11) NULL DEFAULT NULL,
	`is_default` TINYINT(4) NULL DEFAULT '0',
	`is_close_status` TINYINT(4) NULL DEFAULT '0' COMMENT '0 => \'not close\',1 => \'close\'',
	`template_id` INT(11) NULL DEFAULT NULL,
	`customer_email` TINYINT(4) NULL DEFAULT NULL,
	`customer_sms` TINYINT(4) NULL DEFAULT NULL,
	`customer_wp` TINYINT(4) NULL DEFAULT NULL,
	`user_email` TINYINT(4) NULL DEFAULT NULL,
	`user_sms` TINYINT(4) NULL DEFAULT NULL,
	`user_wp` TINYINT(4) NULL DEFAULT NULL,
	`incomming_mail_status` INT(11) NULL DEFAULT '0',
	PRIMARY KEY (`status_id`) USING BTREE
) COLLATE = 'latin1_swedish_ci' ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `tms_queue_rule_master_##QID##`(
	`rule_id` INT NOT NULL AUTO_INCREMENT,
	`rule_name` VARCHAR(50) DEFAULT NULL,
	`match_any_condition` BIT DEFAULT NULL,
	`match_all_condition` BIT DEFAULT NULL,
	`order_no` INT(11) DEFAULT NULL,
	`created_date` DATETIME NULL DEFAULT NULL,
	`created_by` INT(11) DEFAULT NULL,
	`modified_date` DATETIME NULL DEFAULT NULL,
	`modified_by` INT(11) DEFAULT NULL,
	`time_stamp` TIMESTAMP,
	`shift_name` VARCHAR(100) DEFAULT NULL,
	`time_from` TIME DEFAULT NULL,
	`time_to` TIME DEFAULT NULL,
	`is_active` BIT DEFAULT NULL,
	`match` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	PRIMARY KEY(`rule_id`)
);

CREATE TABLE IF NOT EXISTS `tms_queue_rule_condition_##QID##`(
	`rule_condition_id` INT NOT NULL AUTO_INCREMENT,
	`rule_id` INT(11) DEFAULT NULL,
	`evaluate_on` VARCHAR(50) DEFAULT NULL,
	`operator` VARCHAR(50) DEFAULT NULL,
	`evaluate_value` VARCHAR(500) DEFAULT NULL,
	PRIMARY KEY (`rule_condition_id`)
);

CREATE TABLE IF NOT EXISTS `tms_queue_rule_action_##QID##`(
	`rule_action_id` INT NOT NULL AUTO_INCREMENT,
	`rule_id` INT(11) DEFAULT NULL,
	`action` VARCHAR(50) DEFAULT NULL,
	`action_value` VARCHAR(50) DEFAULT NULL,
	PRIMARY KEY (`rule_action_id`)
);

CREATE TABLE IF NOT EXISTS `tms_ticket_master_##QID##`(
	`ticket_prefix` VARCHAR(10) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`ticket_unique_id` INT(11) NOT NULL AUTO_INCREMENT,
	`ticket_id` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`person_name` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`mobile_no` VARCHAR(16) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`unique_id` VARCHAR(15) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`parent_id` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`subject` TEXT DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
	`start_date` DATETIME NULL DEFAULT NULL,
	`from_email` VARCHAR(500) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`to_email` VARCHAR(2000) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`cc_email` VARCHAR(2000) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`bcc_email` VARCHAR(2000) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`start_mode` INT(11) NULL DEFAULT NULL,
	`status_id` INT(11) NULL DEFAULT NULL,
	`priority_id` INT(11) NULL DEFAULT NULL,
	`queue_id` INT(11) NULL DEFAULT NULL,
	`last_updated_on` DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
	`is_read` BIT(1) NULL DEFAULT NULL,
	`read_by` INT(11) NULL DEFAULT NULL,
	`read_date` DATETIME NULL DEFAULT NULL,
	`mail_date` DATETIME NULL DEFAULT NULL,
	`is_assigned` TINYINT(4) NULL DEFAULT NULL,
	`assigned_to` INT(11) NULL DEFAULT NULL,
	`assigned_by` INT(11) NULL DEFAULT '0',
	`assigned_on` DATETIME NULL DEFAULT NULL,
	`last_updated_by` INT(11) NULL DEFAULT NULL,
	`phone_no` VARCHAR(16) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`category_id` INT(11) NULL DEFAULT NULL,
	`subcategory_id` INT(11) NULL DEFAULT NULL,
	`follow_up_date` DATETIME NULL DEFAULT NULL,
	`ticket_created_by` INT(11) NULL DEFAULT NULL,
	`is_assigned_open_ticket` BIT(1) NULL DEFAULT NULL,
	`remarks` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`is_replied_mail` BIT(1) NULL DEFAULT NULL,
	`is_forward_mail` BIT(1) NULL DEFAULT NULL,
	`created_date` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
	`happy_code` INT(11) NULL DEFAULT NULL,
	`escalation_id` INT(11) NULL DEFAULT NULL,
	`last_escalation_on` DATETIME NULL DEFAULT NULL,
	`hold_date` DATETIME NULL DEFAULT NULL,
	`incoming_mail_id` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`is_new` TINYINT(4) NULL DEFAULT '0' COMMENT '0 => not read,1 =>read',
	`parent_ticket_id` INT(11) NULL DEFAULT NULL,
	`parent_ticket_id_text` VARCHAR(30) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`is_junk` TINYINT(4) NULL DEFAULT '0',
	`is_deleted_ticket` TINYINT(4) NULL DEFAULT '0',
	`is_closed` TINYINT(4) NULL DEFAULT '0' COMMENT '0 => not closed,1 =>ticket_closed',
	`is_auto` TINYINT(4) NULL DEFAULT '0',
	`deleted_date` DATETIME NULL DEFAULT NULL,
	`status_changed_on` DATETIME NULL DEFAULT NULL,
	`priority_changed_on` DATETIME NULL DEFAULT NULL,
	`reopen_date` DATETIME NULL DEFAULT NULL,
	`ticket_closed_date` DATETIME NULL DEFAULT NULL,
	`is_draft` TINYINT(4) NULL DEFAULT '0',
	PRIMARY KEY(`ticket_unique_id`),
	CONSTRAINT `FK_##QID##_tms_queue_status_##QID##` FOREIGN KEY (`status_id`) REFERENCES `tms_queue_status_##QID##` (`status_id`) ON UPDATE CASCADE ON DELETE RESTRICT,
	CONSTRAINT `FK_##QID##_tms_queue_priority_##QID##` FOREIGN KEY (`priority_id`) REFERENCES `tms_queue_priority_##QID##` (`priority_id`) ON UPDATE CASCADE ON DELETE RESTRICT,
	CONSTRAINT `FK_tms_ticket_master_##QID##_tms_conversation_type_master` FOREIGN KEY (`start_mode`) REFERENCES `tms_conversation_type_master` (`id`) ON UPDATE CASCADE ON DELETE RESTRICT
);

CREATE TABLE IF NOT EXISTS `tms_conversation_master_##QID##` (
	`conversation_id` int(11) NOT NULL AUTO_INCREMENT,
	`conversation_date` DATETIME null DEFAULT NULL,
	`conversation_type` VARCHAR(50) DEFAULT NULL,
	`ticket_unique_id` INT(11) DEFAULT NULL,
	`ticket_id` VARCHAR(50) DEFAULT NULL,
	`mobile_no` VARCHAR(16) DEFAULT NULL,
	`person_name` VARCHAR(100) DEFAULT NULL,
	`email_uid` VARCHAR(500) DEFAULT NULL,
	`account_id` INT(11) DEFAULT NULL,
	`from_email` VARCHAR(320) DEFAULT NULL,
	`to_email` TEXT DEFAULT NULL,
	`cc_email` TEXT DEFAULT NULL,
	`bcc_email` TEXT DEFAULT NULL,
	`subject` TEXT DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
	`sms_conversation` TEXT DEFAULT NULL,
	`category_id` varchar(50) DEFAULT NULL,
	`subcategory_id` varchar(50) DEFAULT NULL,
	`status_id` INT(11) DEFAULT NULL,
	`priority_id` INT(11) DEFAULT NULL,
	`queue_id` INT(11) DEFAULT NULL,
	`login_id` INT(11) DEFAULT NULL,
	`email_status` VARCHAR(30) DEFAULT NULL,
	`sms_status` VARCHAR(30) DEFAULT NULL,
	`whatsapp_status` VARCHAR(30) DEFAULT NULL,
	`no_of_try` INT(11) DEFAULT NULL,
	`max_try` INT(11) DEFAULT '3',
	`email_message_id` VARCHAR(500) DEFAULT NULL,
	`sms_no_of_try` INT(11) DEFAULT NULL,
	`sms_max_try` INT(11) DEFAULT '3',
	`fetch_xml_uid` VARCHAR(250) DEFAULT NULL,
	`hold_date` DATETIME null DEFAULT NULL,
	`json_file_name` VARCHAR(500) DEFAULT NULL,
	`footer_url` VARCHAR(500) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`is_draft` TINYINT(4) NULL DEFAULT '0',
	PRIMARY KEY (`conversation_id`)
);

CREATE TABLE IF NOT EXISTS `tms_conversation_attachements_##QID##` (
	`attachement_id` int(11) NOT NULL AUTO_INCREMENT,
	`ticket_id` varchar(100) DEFAULT NULL,
	`ticket_unique_id` INT(11) NULL DEFAULT NULL,
	`conversation_id` int(11) DEFAULT NULL,
	`attachement_name` varchar(200) DEFAULT NULL,
	`content_type` varchar(200) DEFAULT NULL,
	`attachement_filepath` varchar(200) DEFAULT NULL,
	PRIMARY KEY (`attachement_id`)
);


CREATE TABLE IF NOT EXISTS `tms_queue_escalationmatrix_##QID##` (
	`escalation_id` INT(11) NOT NULL AUTO_INCREMENT,
	`priority_id` INT(11) NULL DEFAULT NULL,
	`days` INT(11) NULL DEFAULT NULL,
	`hours` INT(11) NULL DEFAULT NULL,
	`minute` INT(11) NULL DEFAULT NULL,
	`emails` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`mobile_no` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`shift_id` INT(11) NULL DEFAULT NULL,
	`template_id` INT(11) NULL DEFAULT NULL,
	`send_email` TINYINT(4) NULL DEFAULT NULL,
	`send_sms` TINYINT(4) NULL DEFAULT NULL,
	`active` TINYINT(4) NULL DEFAULT NULL,
	`level` INT(11) NULL DEFAULT NULL,
	`send_email_agent` TINYINT(4) NULL DEFAULT NULL,
	`agent_template_id` INT(11) NULL DEFAULT NULL,
	PRIMARY KEY (`escalation_id`) USING BTREE,
	CONSTRAINT `FK_##QID##_tms_shift_master` FOREIGN KEY (`shift_id`) REFERENCES `tms_shift_master` (`id`) ON UPDATE CASCADE ON DELETE RESTRICT,
	CONSTRAINT `FK_tms_queue_escalationmatrix_##QID##_tms_queue_priority_##QID##` FOREIGN KEY (`priority_id`) REFERENCES `tms_queue_priority_##QID##` (`priority_id`) ON UPDATE CASCADE ON DELETE RESTRICT,
	CONSTRAINT `FK_tms_queue_escalationmatrix_##QID##_tms_queue_template_##QID##` FOREIGN KEY (`template_id`) REFERENCES `tms_queue_template_##QID##` (`template_id`) ON UPDATE CASCADE ON DELETE RESTRICT
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;

CREATE TABLE `tms_queue_assign_rule_action_##QID##` (
	`rule_action_id` INT(11) NOT NULL AUTO_INCREMENT,
	`assign_rule_id` INT(11) NULL DEFAULT NULL,
	`action` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`action_value` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`assign_to_login` TINYINT(4) NULL DEFAULT '0',
	PRIMARY KEY (`rule_action_id`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;

CREATE TABLE `tms_queue_assign_rule_condition_##QID##` (
	`rule_condition_id` INT(11) NOT NULL AUTO_INCREMENT,
	`assign_rule_id` INT(11) NULL DEFAULT NULL,
	`evaluate_on` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`operator` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`evaluate_value` VARCHAR(500) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	PRIMARY KEY (`rule_condition_id`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB;

CREATE TABLE `tms_queue_assign_rule_master_##QID##` (
	`assign_rule_id` INT(10) NOT NULL AUTO_INCREMENT,
	`rule_name` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`match_any_condition` BIT(1) NULL DEFAULT NULL,
	`match_all_condition` BIT(1) NULL DEFAULT NULL,
	`order_no` INT(10) NULL DEFAULT NULL,
	`created_date` DATETIME NULL DEFAULT NULL,
	`created_by` INT(10) NULL DEFAULT NULL,
	`modified_date` DATETIME NULL DEFAULT NULL,
	`modified_by` INT(10) NULL DEFAULT NULL,
	`time_stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
	`is_active` BIT(1) NULL DEFAULT NULL,
	`match` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`category_id` INT(10) NULL DEFAULT NULL,
	`subcategory_id` INT(10) NULL DEFAULT NULL,
	PRIMARY KEY (`assign_rule_id`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;


CREATE TABLE `tms_statuspermission_##QID##` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`status_id` INT(10) NOT NULL DEFAULT '0',
	`is_checked` INT(10) NOT NULL DEFAULT '0',
	`status_name` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
	`user_type` INT(10) NULL DEFAULT NULL,
	PRIMARY KEY (`id`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;

CREATE TABLE `sms_api_log_##QID##` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`ticket_id` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`conversation_id` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`mobile_no` VARCHAR(20) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`response` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`cr_date` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
	PRIMARY KEY (`id`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;

CREATE TABLE `whatsapp_api_log_##QID##` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`ticket_id` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`conversation_id` VARCHAR(100) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`mobile_no` VARCHAR(20) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`response` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`cr_date` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
	PRIMARY KEY (`id`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;

CREATE TABLE `tms_addressbook_##QID##` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`mailid` VARCHAR(50) NOT NULL COLLATE 'latin1_swedish_ci',
	PRIMARY KEY (`id`) USING BTREE,
	UNIQUE INDEX `mailid` (`mailid`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;
CREATE TABLE `bulk_escalation_data_##QID##` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`email_status` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`from_email` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`to_emails` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`subject` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`conversation` TEXT NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	PRIMARY KEY (`id`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;


