· 7 years ago · Jan 31, 2019, 12:00 PM
1DROP TABLE IF EXISTS `phone_notifications`;
2/*!40101 SET @saved_cs_client = @@character_set_client */;
3/*!40101 SET character_set_client = utf8 */;
4CREATE TABLE `phone_notifications` (
5 `id` int(11) NOT NULL AUTO_INCREMENT,
6 `phone` varchar(255) NOT NULL,
7 `message` text NOT NULL,
8 `ref_table` varchar(255) DEFAULT NULL,
9 `ref_id` int(11) DEFAULT NULL,
10 `state_id` varchar(255) NOT NULL,
11 `created_at` int(11) NOT NULL,
12 `updated_at` int(11) NOT NULL,
13 `created_by_user_id` int(11) NOT NULL,
14 `data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (`data` is null or json_valid(`data`)),
15 `data_sms_id` int(11) GENERATED ALWAYS AS (json_value(`data`,'$.results.sms-local.sendMessageResponseData.smsId')) VIRTUAL,
16 `sms_template_id` int(11) DEFAULT NULL,
17 `data_duplicated_phone_notification_id` int(11) GENERATED ALWAYS AS (json_value(`data`,'$.duplicateData.notificationId')) VIRTUAL,
18 PRIMARY KEY (`id`),
19 UNIQUE KEY `phone_notifications_data_sms_id_ui` (`data_sms_id`),
20 UNIQUE KEY `phone_notifications_data_duplicated_phone_notification_id_ui` (`data_duplicated_phone_notification_id`),
21 KEY `phone_notifications_state_id_foreign` (`state_id`),
22 KEY `phone_notifications_created_by_user_id_foreign` (`created_by_user_id`),
23 KEY `phone_notifications_phone_index` (`phone`),
24 KEY `phone_notifications_ref_table_ref_id_index` (`ref_table`,`ref_id`),
25 KEY `phone_notification_sms_template_id_fk` (`sms_template_id`),
26 FULLTEXT KEY `phone_notifications_data_fti` (`data`),
27 FULLTEXT KEY `phone_notification_message_ft_i` (`message`),
28 CONSTRAINT `phone_notification_sms_template_id_fk` FOREIGN KEY (`sms_template_id`) REFERENCES `sms_templates` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
29 CONSTRAINT `phone_notifications_created_by_user_id_foreign` FOREIGN KEY (`created_by_user_id`) REFERENCES `users` (`id`) ON UPDATE CASCADE,
30 CONSTRAINT `phone_notifications_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `labels` (`id`) ON UPDATE CASCADE
31) ENGINE=InnoDB AUTO_INCREMENT=5232277 DEFAULT CHARSET=cp1251;
32/*!40101 SET character_set_client = @saved_cs_client */;