/docker/mysql/init-sql/01-chatengine.sql

https://github.com/nebula-chat/chatengine · SQL · 1087 lines · 846 code · 58 blank · 183 comment · 0 complexity · 9fe2ae9e66848d948c20c28180d1ae56 MD5 · raw file

  1. /*
  2. Navicat Premium Data Transfer
  3. Source Server : localhost-chatengine
  4. Source Server Type : MySQL
  5. Source Server Version : 50717
  6. Source Host : localhost:3307
  7. Source Schema : chatengine
  8. Target Server Type : MySQL
  9. Target Server Version : 50717
  10. File Encoding : 65001
  11. Date: 04/03/2020 00:03:38
  12. */
  13. SET NAMES utf8mb4;
  14. SET FOREIGN_KEY_CHECKS = 0;
  15. -- ----------------------------
  16. -- Table structure for app_configs
  17. -- ----------------------------
  18. DROP TABLE IF EXISTS `app_configs`;
  19. CREATE TABLE `app_configs` (
  20. `app_id` int(11) NOT NULL AUTO_INCREMENT,
  21. `config_key` int(11) NOT NULL,
  22. `config_value` int(11) NOT NULL,
  23. `status` tinyint(4) NOT NULL DEFAULT '0',
  24. `created_at` int(11) NOT NULL,
  25. `updated_at` int(11) NOT NULL,
  26. PRIMARY KEY (`app_id`)
  27. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  28. -- ----------------------------
  29. -- Table structure for app_ios_push_certs
  30. -- ----------------------------
  31. DROP TABLE IF EXISTS `app_ios_push_certs`;
  32. CREATE TABLE `app_ios_push_certs` (
  33. `cert_id` int(11) NOT NULL AUTO_INCREMENT,
  34. `app_id` int(11) NOT NULL,
  35. `bundle_id` int(11) NOT NULL,
  36. `cert_type` int(11) NOT NULL,
  37. `cert_memo` int(11) NOT NULL,
  38. `uploaded` int(11) NOT NULL,
  39. `expired` int(11) NOT NULL,
  40. `status` tinyint(4) NOT NULL DEFAULT '0',
  41. `created_at` int(11) NOT NULL,
  42. `updated_at` int(11) NOT NULL,
  43. PRIMARY KEY (`cert_id`)
  44. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  45. -- ----------------------------
  46. -- Table structure for app_keys
  47. -- ----------------------------
  48. DROP TABLE IF EXISTS `app_keys`;
  49. CREATE TABLE `app_keys` (
  50. `app_id` int(11) NOT NULL,
  51. `app_key` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL,
  52. `app_secret` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL,
  53. `status` tinyint(4) NOT NULL DEFAULT '0',
  54. `created_at` int(11) NOT NULL,
  55. `refresher` int(11) NOT NULL,
  56. `refreshed_at` int(11) NOT NULL,
  57. PRIMARY KEY (`app_id`)
  58. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  59. -- ----------------------------
  60. -- Table structure for apps
  61. -- ----------------------------
  62. DROP TABLE IF EXISTS `apps`;
  63. CREATE TABLE `apps` (
  64. `id` int(11) NOT NULL AUTO_INCREMENT,
  65. `api_id` int(11) NOT NULL,
  66. `api_hash` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL,
  67. `title` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
  68. `short_name` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
  69. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  70. `deleted_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  71. PRIMARY KEY (`id`),
  72. UNIQUE KEY `api_id` (`api_id`)
  73. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='apps';
  74. -- ----------------------------
  75. -- Table structure for auth_keys
  76. -- ----------------------------
  77. DROP TABLE IF EXISTS `auth_keys`;
  78. CREATE TABLE `auth_keys` (
  79. `id` int(11) NOT NULL AUTO_INCREMENT,
  80. `auth_key_id` bigint(20) NOT NULL COMMENT 'auth_id',
  81. `body` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'auth_key,原始数据为256的二进制数据,存储时转换成base64格式',
  82. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  83. PRIMARY KEY (`id`),
  84. UNIQUE KEY `auth_key_id` (`auth_key_id`)
  85. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  86. -- ----------------------------
  87. -- Table structure for auth_op_logs
  88. -- ----------------------------
  89. DROP TABLE IF EXISTS `auth_op_logs`;
  90. CREATE TABLE `auth_op_logs` (
  91. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  92. `auth_key_id` bigint(11) NOT NULL,
  93. `ip` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  94. `op_type` int(11) NOT NULL DEFAULT '1',
  95. `log_text` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL,
  96. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  97. PRIMARY KEY (`id`)
  98. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  99. -- ----------------------------
  100. -- Table structure for auth_phone_transactions
  101. -- ----------------------------
  102. DROP TABLE IF EXISTS `auth_phone_transactions`;
  103. CREATE TABLE `auth_phone_transactions` (
  104. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  105. `auth_key_id` bigint(20) NOT NULL,
  106. `phone_number` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  107. `code` varchar(8) COLLATE utf8mb4_unicode_ci NOT NULL,
  108. `code_expired` int(11) NOT NULL DEFAULT '0',
  109. `code_msg_id` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  110. `transaction_hash` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
  111. `sent_code_type` tinyint(4) NOT NULL DEFAULT '0',
  112. `flash_call_pattern` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  113. `next_code_type` tinyint(4) NOT NULL DEFAULT '0',
  114. `state` tinyint(4) NOT NULL DEFAULT '0',
  115. `api_id` int(11) NOT NULL,
  116. `api_hash` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
  117. `attempts` int(11) NOT NULL DEFAULT '0',
  118. `created_time` bigint(20) NOT NULL,
  119. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  120. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  121. `is_deleted` tinyint(4) NOT NULL DEFAULT '0',
  122. PRIMARY KEY (`id`),
  123. UNIQUE KEY `transaction_hash` (`transaction_hash`)
  124. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  125. -- ----------------------------
  126. -- Table structure for auth_salts
  127. -- ----------------------------
  128. DROP TABLE IF EXISTS `auth_salts`;
  129. CREATE TABLE `auth_salts` (
  130. `id` int(11) NOT NULL AUTO_INCREMENT,
  131. `auth_key_id` bigint(20) NOT NULL,
  132. `salt` bigint(20) NOT NULL,
  133. `valid_since` int(11) NOT NULL DEFAULT '0',
  134. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  135. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  136. PRIMARY KEY (`id`),
  137. KEY `auth` (`auth_key_id`)
  138. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  139. -- ----------------------------
  140. -- Table structure for auth_seq_updates
  141. -- ----------------------------
  142. DROP TABLE IF EXISTS `auth_seq_updates`;
  143. CREATE TABLE `auth_seq_updates` (
  144. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  145. `auth_id` bigint(20) NOT NULL,
  146. `user_id` int(11) NOT NULL,
  147. `seq` int(11) NOT NULL,
  148. `update_type` int(11) NOT NULL,
  149. `update_data` blob NOT NULL,
  150. `date2` int(11) NOT NULL,
  151. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  152. PRIMARY KEY (`id`),
  153. UNIQUE KEY `auth_id` (`auth_id`,`user_id`,`seq`)
  154. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  155. -- ----------------------------
  156. -- Table structure for auth_updates_state
  157. -- ----------------------------
  158. DROP TABLE IF EXISTS `auth_updates_state`;
  159. CREATE TABLE `auth_updates_state` (
  160. `id` int(11) NOT NULL AUTO_INCREMENT,
  161. `auth_key_id` bigint(20) NOT NULL,
  162. `user_id` int(11) NOT NULL,
  163. `pts` int(11) NOT NULL DEFAULT '0',
  164. `pts2` int(11) NOT NULL DEFAULT '0',
  165. `qts` int(11) NOT NULL DEFAULT '0',
  166. `qts2` int(11) NOT NULL DEFAULT '0',
  167. `seq` int(11) NOT NULL DEFAULT '-1',
  168. `seq2` int(11) NOT NULL DEFAULT '-1',
  169. `date` int(11) NOT NULL,
  170. `date2` int(11) NOT NULL DEFAULT '0',
  171. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  172. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  173. `deleted_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  174. PRIMARY KEY (`id`),
  175. UNIQUE KEY `auth_key_id` (`auth_key_id`,`user_id`)
  176. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  177. -- ----------------------------
  178. -- Table structure for auth_users
  179. -- ----------------------------
  180. DROP TABLE IF EXISTS `auth_users`;
  181. CREATE TABLE `auth_users` (
  182. `id` int(11) NOT NULL AUTO_INCREMENT,
  183. `auth_key_id` bigint(20) NOT NULL,
  184. `user_id` int(11) NOT NULL DEFAULT '0',
  185. `hash` bigint(20) NOT NULL DEFAULT '0',
  186. `layer` int(11) NOT NULL DEFAULT '0',
  187. `device_model` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  188. `platform` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  189. `system_version` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  190. `api_id` int(11) NOT NULL DEFAULT '0',
  191. `app_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  192. `app_version` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  193. `date_created` int(11) NOT NULL DEFAULT '0',
  194. `date_actived` int(11) NOT NULL DEFAULT '0',
  195. `ip` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  196. `country` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  197. `region` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  198. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  199. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  200. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  201. PRIMARY KEY (`id`),
  202. UNIQUE KEY `auth_key_id` (`auth_key_id`,`user_id`),
  203. KEY `auth_key_id_2` (`auth_key_id`,`user_id`,`deleted`)
  204. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  205. -- ----------------------------
  206. -- Table structure for auths
  207. -- ----------------------------
  208. DROP TABLE IF EXISTS `auths`;
  209. CREATE TABLE `auths` (
  210. `id` int(11) NOT NULL AUTO_INCREMENT,
  211. `auth_key_id` bigint(20) NOT NULL,
  212. `layer` int(11) NOT NULL DEFAULT '0',
  213. `api_id` int(11) NOT NULL,
  214. `device_model` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  215. `system_version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  216. `app_version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  217. `system_lang_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  218. `lang_pack` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  219. `lang_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  220. `client_ip` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  221. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  222. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  223. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  224. PRIMARY KEY (`id`),
  225. UNIQUE KEY `auth_key_id` (`auth_key_id`)
  226. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  227. -- ----------------------------
  228. -- Table structure for banned
  229. -- ----------------------------
  230. DROP TABLE IF EXISTS `banned`;
  231. CREATE TABLE `banned` (
  232. `id` int(11) NOT NULL AUTO_INCREMENT,
  233. `phone` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  234. `banned_time` bigint(20) NOT NULL,
  235. `expires` bigint(20) NOT NULL DEFAULT '0',
  236. `banned_reason` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  237. `log` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  238. `state` tinyint(4) NOT NULL DEFAULT '0',
  239. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  240. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  241. PRIMARY KEY (`id`),
  242. UNIQUE KEY `user_id` (`phone`)
  243. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  244. -- ----------------------------
  245. -- Table structure for blocks
  246. -- ----------------------------
  247. DROP TABLE IF EXISTS `blocks`;
  248. CREATE TABLE `blocks` (
  249. `id` int(11) NOT NULL AUTO_INCREMENT,
  250. `user_id` int(11) NOT NULL,
  251. `type` int(11) NOT NULL DEFAULT '0',
  252. `block_id` int(11) NOT NULL DEFAULT '0',
  253. `blocked_id` int(11) NOT NULL DEFAULT '0',
  254. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  255. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  256. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  257. PRIMARY KEY (`id`)
  258. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  259. -- ----------------------------
  260. -- Table structure for bot_commands
  261. -- ----------------------------
  262. DROP TABLE IF EXISTS `bot_commands`;
  263. CREATE TABLE `bot_commands` (
  264. `id` int(11) NOT NULL AUTO_INCREMENT,
  265. `bot_id` int(11) NOT NULL,
  266. `command` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  267. `description` varchar(10240) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  268. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  269. PRIMARY KEY (`id`),
  270. KEY `bot_id` (`bot_id`)
  271. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  272. -- ----------------------------
  273. -- Table structure for bots
  274. -- ----------------------------
  275. DROP TABLE IF EXISTS `bots`;
  276. CREATE TABLE `bots` (
  277. `id` int(11) NOT NULL AUTO_INCREMENT,
  278. `bot_id` int(11) NOT NULL,
  279. `bot_type` tinyint(4) NOT NULL DEFAULT '0',
  280. `description` varchar(10240) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  281. `bot_chat_history` tinyint(4) NOT NULL DEFAULT '0',
  282. `bot_nochats` tinyint(4) NOT NULL DEFAULT '1',
  283. `verified` tinyint(4) NOT NULL DEFAULT '0',
  284. `bot_inline_geo` tinyint(4) NOT NULL DEFAULT '0',
  285. `bot_info_version` int(11) NOT NULL DEFAULT '1',
  286. `bot_inline_placeholder` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  287. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  288. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  289. PRIMARY KEY (`id`),
  290. UNIQUE KEY `bot_id` (`bot_id`)
  291. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  292. -- ----------------------------
  293. -- Table structure for channel_messages2
  294. -- ----------------------------
  295. DROP TABLE IF EXISTS `channel_messages2`;
  296. CREATE TABLE `channel_messages2` (
  297. `id` int(11) NOT NULL AUTO_INCREMENT,
  298. `channel_id` int(11) NOT NULL,
  299. `sender_user_id` int(11) NOT NULL,
  300. `channel_message_box_id` int(11) NOT NULL,
  301. `dialog_message_id` bigint(20) NOT NULL,
  302. `random_id` bigint(20) NOT NULL,
  303. `message_type` tinyint(4) NOT NULL DEFAULT '0',
  304. `message_data` text COLLATE utf8mb4_unicode_ci NOT NULL,
  305. `date2` int(11) NOT NULL DEFAULT '0',
  306. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  307. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  308. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  309. PRIMARY KEY (`id`)
  310. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  311. -- ----------------------------
  312. -- Table structure for chat_participants
  313. -- ----------------------------
  314. DROP TABLE IF EXISTS `chat_participants`;
  315. CREATE TABLE `chat_participants` (
  316. `id` int(11) NOT NULL AUTO_INCREMENT,
  317. `chat_id` int(11) NOT NULL,
  318. `user_id` int(11) NOT NULL,
  319. `participant_type` tinyint(4) DEFAULT '0',
  320. `inviter_user_id` int(11) NOT NULL DEFAULT '0',
  321. `invited_at` int(11) NOT NULL DEFAULT '0',
  322. `kicked_at` int(11) NOT NULL DEFAULT '0',
  323. `left_at` int(11) NOT NULL DEFAULT '0',
  324. `state` tinyint(4) NOT NULL DEFAULT '0',
  325. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  326. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  327. PRIMARY KEY (`id`),
  328. UNIQUE KEY `chat_id_2` (`chat_id`,`user_id`),
  329. KEY `chat_id` (`chat_id`)
  330. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  331. -- ----------------------------
  332. -- Table structure for chats
  333. -- ----------------------------
  334. DROP TABLE IF EXISTS `chats`;
  335. CREATE TABLE `chats` (
  336. `id` int(11) NOT NULL AUTO_INCREMENT,
  337. `creator_user_id` int(11) NOT NULL,
  338. `access_hash` bigint(20) NOT NULL,
  339. `random_id` bigint(20) NOT NULL,
  340. `participant_count` int(11) NOT NULL,
  341. `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  342. `link` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  343. `photo_id` bigint(20) NOT NULL DEFAULT '0',
  344. `admins_enabled` tinyint(4) NOT NULL DEFAULT '0',
  345. `migrated_to` int(11) NOT NULL DEFAULT '0',
  346. `deactivated` tinyint(4) NOT NULL DEFAULT '0',
  347. `version` int(11) NOT NULL DEFAULT '1',
  348. `date` int(11) NOT NULL DEFAULT '0',
  349. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  350. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  351. PRIMARY KEY (`id`)
  352. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  353. -- ----------------------------
  354. -- Table structure for devices
  355. -- ----------------------------
  356. DROP TABLE IF EXISTS `devices`;
  357. CREATE TABLE `devices` (
  358. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  359. `auth_key_id` bigint(20) NOT NULL,
  360. `user_id` int(11) NOT NULL,
  361. `token_type` tinyint(4) NOT NULL,
  362. `token` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
  363. `app_sandbox` tinyint(4) NOT NULL DEFAULT '0',
  364. `secret` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  365. `other_uids` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  366. `state` tinyint(4) NOT NULL DEFAULT '0',
  367. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  368. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  369. PRIMARY KEY (`id`),
  370. UNIQUE KEY `auth_key_id` (`auth_key_id`,`user_id`,`token_type`)
  371. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  372. -- ----------------------------
  373. -- Table structure for documents
  374. -- ----------------------------
  375. DROP TABLE IF EXISTS `documents`;
  376. CREATE TABLE `documents` (
  377. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  378. `document_id` bigint(20) NOT NULL,
  379. `access_hash` bigint(20) NOT NULL,
  380. `dc_id` int(11) NOT NULL,
  381. `file_path` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  382. `file_size` int(11) NOT NULL,
  383. `uploaded_file_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  384. `ext` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  385. `mime_type` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  386. `thumb_id` bigint(20) NOT NULL DEFAULT '0',
  387. `version` int(11) NOT NULL DEFAULT '0',
  388. `attributes` text COLLATE utf8mb4_unicode_ci NOT NULL,
  389. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  390. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  391. PRIMARY KEY (`id`)
  392. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  393. -- ----------------------------
  394. -- Table structure for file_parts
  395. -- ----------------------------
  396. DROP TABLE IF EXISTS `file_parts`;
  397. CREATE TABLE `file_parts` (
  398. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  399. `creator_id` bigint(20) NOT NULL DEFAULT '0',
  400. `creator_user_id` int(11) NOT NULL DEFAULT '0',
  401. `file_id` bigint(20) NOT NULL DEFAULT '0',
  402. `file_part_id` bigint(20) NOT NULL,
  403. `file_part` int(11) NOT NULL DEFAULT '0',
  404. `is_big_file` tinyint(4) NOT NULL DEFAULT '0',
  405. `file_total_parts` int(11) NOT NULL DEFAULT '0',
  406. `file_path` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  407. `file_size` bigint(20) NOT NULL DEFAULT '0',
  408. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  409. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  410. PRIMARY KEY (`id`)
  411. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  412. -- ----------------------------
  413. -- Table structure for files
  414. -- ----------------------------
  415. DROP TABLE IF EXISTS `files`;
  416. CREATE TABLE `files` (
  417. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  418. `file_id` bigint(20) NOT NULL,
  419. `access_hash` bigint(20) NOT NULL,
  420. `creator_id` bigint(20) NOT NULL DEFAULT '0',
  421. `creator_user_id` int(11) NOT NULL DEFAULT '0',
  422. `file_part_id` bigint(20) NOT NULL DEFAULT '0',
  423. `file_parts` int(11) NOT NULL DEFAULT '0',
  424. `file_size` bigint(20) NOT NULL,
  425. `file_path` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  426. `ext` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  427. `is_big_file` tinyint(4) NOT NULL DEFAULT '0',
  428. `md5_checksum` char(33) COLLATE utf8mb4_unicode_ci NOT NULL,
  429. `upload_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  430. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  431. PRIMARY KEY (`id`)
  432. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  433. -- ----------------------------
  434. -- Table structure for imported_contacts
  435. -- ----------------------------
  436. DROP TABLE IF EXISTS `imported_contacts`;
  437. CREATE TABLE `imported_contacts` (
  438. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  439. `user_id` int(11) NOT NULL,
  440. `imported_user_id` int(11) NOT NULL,
  441. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  442. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  443. PRIMARY KEY (`id`),
  444. UNIQUE KEY `user_id` (`user_id`),
  445. UNIQUE KEY `user_id_2` (`user_id`,`imported_user_id`)
  446. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  447. -- ----------------------------
  448. -- Table structure for message_boxes
  449. -- ----------------------------
  450. DROP TABLE IF EXISTS `message_boxes`;
  451. CREATE TABLE `message_boxes` (
  452. `id` int(11) NOT NULL AUTO_INCREMENT,
  453. `user_id` int(11) NOT NULL,
  454. `user_message_box_id` int(11) NOT NULL,
  455. `dialog_id` bigint(20) NOT NULL DEFAULT '0',
  456. `dialog_message_id` int(11) NOT NULL,
  457. `message_data_id` bigint(20) NOT NULL,
  458. `pts` int(11) NOT NULL DEFAULT '0',
  459. `message_box_type` tinyint(4) NOT NULL,
  460. `reply_to_msg_id` int(11) NOT NULL DEFAULT '0',
  461. `mentioned` tinyint(4) NOT NULL DEFAULT '0',
  462. `media_unread` tinyint(4) NOT NULL DEFAULT '0',
  463. `date2` int(11) NOT NULL DEFAULT '0',
  464. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  465. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  466. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  467. PRIMARY KEY (`id`),
  468. UNIQUE KEY `user_id` (`user_id`,`message_data_id`)
  469. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  470. -- ----------------------------
  471. -- Table structure for message_datas
  472. -- ----------------------------
  473. DROP TABLE IF EXISTS `message_datas`;
  474. CREATE TABLE `message_datas` (
  475. `id` int(11) NOT NULL AUTO_INCREMENT,
  476. `message_data_id` bigint(20) NOT NULL,
  477. `dialog_id` bigint(20) NOT NULL,
  478. `dialog_message_id` int(11) NOT NULL DEFAULT '0',
  479. `sender_user_id` int(11) NOT NULL,
  480. `peer_type` tinyint(4) NOT NULL,
  481. `peer_id` int(11) NOT NULL,
  482. `random_id` bigint(20) NOT NULL,
  483. `message_type` tinyint(4) NOT NULL DEFAULT '0',
  484. `message_data` text COLLATE utf8mb4_unicode_ci NOT NULL,
  485. `media_unread` tinyint(4) NOT NULL DEFAULT '0',
  486. `has_media_unread` tinyint(4) NOT NULL DEFAULT '0',
  487. `date` int(11) NOT NULL DEFAULT '0',
  488. `edit_message` text COLLATE utf8mb4_unicode_ci NOT NULL,
  489. `edit_date` int(11) NOT NULL DEFAULT '0',
  490. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  491. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  492. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  493. PRIMARY KEY (`id`),
  494. UNIQUE KEY `dialog_id` (`dialog_id`,`dialog_message_id`),
  495. UNIQUE KEY `sender_user_id` (`sender_user_id`,`random_id`),
  496. UNIQUE KEY `message_data_id` (`message_data_id`)
  497. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  498. -- ----------------------------
  499. -- Table structure for messages
  500. -- ----------------------------
  501. DROP TABLE IF EXISTS `messages`;
  502. CREATE TABLE `messages` (
  503. `id` int(11) NOT NULL AUTO_INCREMENT,
  504. `user_id` int(11) NOT NULL,
  505. `user_message_box_id` int(11) NOT NULL,
  506. `dialog_message_id` bigint(20) NOT NULL,
  507. `sender_user_id` int(11) NOT NULL,
  508. `message_box_type` tinyint(4) NOT NULL,
  509. `peer_type` tinyint(4) NOT NULL,
  510. `peer_id` int(11) NOT NULL,
  511. `random_id` bigint(20) NOT NULL,
  512. `message_type` tinyint(4) NOT NULL DEFAULT '0',
  513. `message_data` text COLLATE utf8mb4_unicode_ci NOT NULL,
  514. `date2` int(11) NOT NULL DEFAULT '0',
  515. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  516. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  517. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  518. PRIMARY KEY (`id`)
  519. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  520. -- ----------------------------
  521. -- Table structure for orgs
  522. -- ----------------------------
  523. DROP TABLE IF EXISTS `orgs`;
  524. CREATE TABLE `orgs` (
  525. `org_id` int(11) NOT NULL AUTO_INCREMENT,
  526. `account_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  527. `passwd` char(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  528. `org_name` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL,
  529. `mail` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  530. `mobile` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  531. `status` tinyint(4) NOT NULL DEFAULT '0',
  532. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  533. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  534. PRIMARY KEY (`org_id`),
  535. UNIQUE KEY `account_name` (`account_name`)
  536. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  537. -- ----------------------------
  538. -- Table structure for phone_books
  539. -- ----------------------------
  540. DROP TABLE IF EXISTS `phone_books`;
  541. CREATE TABLE `phone_books` (
  542. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  543. `auth_key_id` bigint(20) NOT NULL,
  544. `client_id` bigint(20) NOT NULL,
  545. `phone` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  546. `first_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  547. `last_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  548. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  549. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  550. PRIMARY KEY (`id`),
  551. UNIQUE KEY `auth_key_id` (`auth_key_id`,`client_id`)
  552. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  553. -- ----------------------------
  554. -- Table structure for phone_call_sessions
  555. -- ----------------------------
  556. DROP TABLE IF EXISTS `phone_call_sessions`;
  557. CREATE TABLE `phone_call_sessions` (
  558. `id` int(11) NOT NULL AUTO_INCREMENT,
  559. `call_session_id` bigint(20) NOT NULL,
  560. `admin_id` int(11) NOT NULL,
  561. `admin_access_hash` bigint(20) NOT NULL,
  562. `participant_id` int(11) NOT NULL,
  563. `participant_access_hash` bigint(20) NOT NULL,
  564. `udp_p2p` tinyint(4) NOT NULL DEFAULT '0',
  565. `udp_reflector` tinyint(4) NOT NULL DEFAULT '0',
  566. `min_layer` int(11) NOT NULL,
  567. `max_layer` int(11) NOT NULL,
  568. `g_a` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  569. `g_b` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  570. `state` int(11) NOT NULL DEFAULT '0',
  571. `admin_debug_data` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  572. `participant_debug_data` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  573. `date` int(11) NOT NULL,
  574. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  575. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  576. PRIMARY KEY (`id`),
  577. UNIQUE KEY `call_session_id` (`call_session_id`)
  578. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  579. -- ----------------------------
  580. -- Table structure for phones
  581. -- ----------------------------
  582. DROP TABLE IF EXISTS `phones`;
  583. CREATE TABLE `phones` (
  584. `id` int(11) NOT NULL AUTO_INCREMENT,
  585. `user_id` int(11) NOT NULL,
  586. `phone` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  587. `region` varchar(8) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'CN',
  588. `region_code` varchar(8) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '86',
  589. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  590. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  591. `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  592. PRIMARY KEY (`id`),
  593. UNIQUE KEY `phone` (`phone`),
  594. KEY `user_id` (`user_id`)
  595. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  596. -- ----------------------------
  597. -- Table structure for photo_datas
  598. -- ----------------------------
  599. DROP TABLE IF EXISTS `photo_datas`;
  600. CREATE TABLE `photo_datas` (
  601. `id` int(11) NOT NULL AUTO_INCREMENT,
  602. `photo_id` bigint(20) NOT NULL,
  603. `photo_type` tinyint(4) NOT NULL,
  604. `dc_id` int(11) NOT NULL,
  605. `volume_id` bigint(20) NOT NULL,
  606. `local_id` int(11) NOT NULL,
  607. `access_hash` bigint(20) NOT NULL,
  608. `width` int(11) NOT NULL,
  609. `height` int(11) NOT NULL,
  610. `file_size` int(11) NOT NULL DEFAULT '0',
  611. `file_path` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  612. `ext` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  613. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  614. PRIMARY KEY (`id`)
  615. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  616. -- ----------------------------
  617. -- Table structure for photos
  618. -- ----------------------------
  619. DROP TABLE IF EXISTS `photos`;
  620. CREATE TABLE `photos` (
  621. `id` int(11) NOT NULL AUTO_INCREMENT,
  622. `photo_id` int(11) NOT NULL,
  623. `has_stickers` int(11) NOT NULL DEFAULT '0',
  624. `access_hash` int(11) NOT NULL,
  625. `date` int(11) NOT NULL DEFAULT '0',
  626. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  627. PRIMARY KEY (`id`)
  628. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  629. -- ----------------------------
  630. -- Table structure for popular_contacts
  631. -- ----------------------------
  632. DROP TABLE IF EXISTS `popular_contacts`;
  633. CREATE TABLE `popular_contacts` (
  634. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  635. `phone` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  636. `importers` int(11) NOT NULL DEFAULT '1',
  637. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  638. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  639. `update_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  640. PRIMARY KEY (`id`),
  641. UNIQUE KEY `phone` (`phone`)
  642. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  643. -- ----------------------------
  644. -- Table structure for push_credentials
  645. -- ----------------------------
  646. DROP TABLE IF EXISTS `push_credentials`;
  647. CREATE TABLE `push_credentials` (
  648. `id` int(11) NOT NULL AUTO_INCREMENT,
  649. `auth_id` bigint(20) NOT NULL,
  650. `user_id` int(11) NOT NULL,
  651. `token_type` tinyint(4) NOT NULL,
  652. `token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  653. `state` tinyint(4) NOT NULL DEFAULT '0',
  654. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  655. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  656. PRIMARY KEY (`id`),
  657. KEY `auth_id` (`auth_id`,`user_id`)
  658. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  659. -- ----------------------------
  660. -- Table structure for reports
  661. -- ----------------------------
  662. DROP TABLE IF EXISTS `reports`;
  663. CREATE TABLE `reports` (
  664. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  665. `user_id` int(11) NOT NULL,
  666. `peer_type` int(11) NOT NULL,
  667. `peer_id` int(11) NOT NULL,
  668. `reason` tinyint(4) NOT NULL DEFAULT '0',
  669. `content` varchar(10000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  670. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  671. PRIMARY KEY (`id`)
  672. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  673. -- ----------------------------
  674. -- Table structure for sticker_data
  675. -- ----------------------------
  676. DROP TABLE IF EXISTS `sticker_data`;
  677. CREATE TABLE `sticker_data` (
  678. `id` int(11) NOT NULL,
  679. `pack_id` int(11) NOT NULL,
  680. `emoji` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  681. `image_128_file_id` bigint(20) NOT NULL,
  682. `image_128_file_hash` bigint(20) NOT NULL,
  683. `image_128_file_size` bigint(20) NOT NULL,
  684. `image_256_file_id` bigint(20) DEFAULT NULL,
  685. `image_256_file_hash` bigint(20) DEFAULT NULL,
  686. `image_256_file_size` bigint(20) DEFAULT NULL,
  687. `image_512_file_id` bigint(20) DEFAULT NULL,
  688. `image_512_file_hash` bigint(20) DEFAULT NULL,
  689. `image_512_file_size` bigint(20) DEFAULT NULL,
  690. `image_128_width` int(11) NOT NULL DEFAULT '128',
  691. `image_128_height` int(11) NOT NULL DEFAULT '128',
  692. `image_256_width` int(11) DEFAULT '256',
  693. `image_256_height` int(11) DEFAULT '256',
  694. `image_512_width` int(11) DEFAULT '512',
  695. `image_512_height` int(11) DEFAULT '512',
  696. PRIMARY KEY (`id`,`pack_id`)
  697. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  698. -- ----------------------------
  699. -- Table structure for sticker_packs
  700. -- ----------------------------
  701. DROP TABLE IF EXISTS `sticker_packs`;
  702. CREATE TABLE `sticker_packs` (
  703. `id` int(11) NOT NULL AUTO_INCREMENT,
  704. `sticker_set_id` bigint(20) NOT NULL,
  705. `emoticon` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  706. `document_id` bigint(20) NOT NULL,
  707. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  708. PRIMARY KEY (`id`)
  709. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  710. -- ----------------------------
  711. -- Table structure for sticker_sets
  712. -- ----------------------------
  713. DROP TABLE IF EXISTS `sticker_sets`;
  714. CREATE TABLE `sticker_sets` (
  715. `id` int(11) NOT NULL AUTO_INCREMENT,
  716. `sticker_set_id` bigint(20) NOT NULL,
  717. `access_hash` bigint(20) NOT NULL,
  718. `title` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  719. `short_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  720. `count` int(11) NOT NULL DEFAULT '0',
  721. `hash` int(11) NOT NULL DEFAULT '0',
  722. `official` tinyint(4) NOT NULL DEFAULT '0',
  723. `mask` tinyint(4) NOT NULL DEFAULT '0',
  724. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  725. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  726. PRIMARY KEY (`id`),
  727. UNIQUE KEY `sticker_set_id` (`sticker_set_id`)
  728. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  729. -- ----------------------------
  730. -- Table structure for tmp_passwords
  731. -- ----------------------------
  732. DROP TABLE IF EXISTS `tmp_passwords`;
  733. CREATE TABLE `tmp_passwords` (
  734. `id` int(11) NOT NULL AUTO_INCREMENT,
  735. `auth_id` bigint(20) NOT NULL,
  736. `user_id` int(11) NOT NULL,
  737. `password_hash` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL,
  738. `period` int(11) NOT NULL,
  739. `tmp_password` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL,
  740. `valid_until` int(11) NOT NULL,
  741. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  742. PRIMARY KEY (`id`)
  743. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  744. -- ----------------------------
  745. -- Table structure for unread_mentions
  746. -- ----------------------------
  747. DROP TABLE IF EXISTS `unread_mentions`;
  748. CREATE TABLE `unread_mentions` (
  749. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  750. `user_id` int(11) NOT NULL,
  751. `peer_type` tinyint(4) NOT NULL,
  752. `peer_id` int(11) NOT NULL,
  753. `mentioned_message_id` int(11) NOT NULL,
  754. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  755. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  756. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  757. PRIMARY KEY (`id`),
  758. UNIQUE KEY `user_id` (`user_id`,`peer_type`,`peer_id`,`mentioned_message_id`)
  759. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  760. -- ----------------------------
  761. -- Table structure for unregistered_contacts
  762. -- ----------------------------
  763. DROP TABLE IF EXISTS `unregistered_contacts`;
  764. CREATE TABLE `unregistered_contacts` (
  765. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  766. `phone` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  767. `importer_user_id` int(11) NOT NULL,
  768. `import_first_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  769. `import_last_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  770. `imported` tinyint(4) NOT NULL DEFAULT '0',
  771. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  772. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  773. PRIMARY KEY (`id`),
  774. UNIQUE KEY `phone` (`phone`,`importer_user_id`),
  775. KEY `phone_2` (`phone`,`importer_user_id`,`imported`)
  776. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  777. -- ----------------------------
  778. -- Table structure for user_blocks
  779. -- ----------------------------
  780. DROP TABLE IF EXISTS `user_blocks`;
  781. CREATE TABLE `user_blocks` (
  782. `id` int(11) NOT NULL AUTO_INCREMENT,
  783. `user_id` int(11) NOT NULL,
  784. `block_id` int(11) NOT NULL DEFAULT '0',
  785. `date` int(11) NOT NULL DEFAULT '0',
  786. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  787. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  788. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  789. PRIMARY KEY (`id`),
  790. UNIQUE KEY `user_id` (`user_id`,`block_id`),
  791. KEY `user_id_2` (`user_id`,`block_id`,`deleted`)
  792. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  793. -- ----------------------------
  794. -- Table structure for user_contacts
  795. -- ----------------------------
  796. DROP TABLE IF EXISTS `user_contacts`;
  797. CREATE TABLE `user_contacts` (
  798. `id` int(11) NOT NULL AUTO_INCREMENT,
  799. `owner_user_id` int(11) NOT NULL,
  800. `contact_user_id` int(11) NOT NULL,
  801. `contact_phone` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  802. `contact_first_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  803. `contact_last_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  804. `mutual` tinyint(4) NOT NULL DEFAULT '0',
  805. `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
  806. `date2` int(11) NOT NULL,
  807. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  808. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  809. PRIMARY KEY (`id`),
  810. UNIQUE KEY `owner_user_id_2` (`owner_user_id`,`contact_phone`),
  811. KEY `owner_user_id` (`owner_user_id`,`contact_user_id`)
  812. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  813. -- ----------------------------
  814. -- Table structure for user_dialogs
  815. -- ----------------------------
  816. DROP TABLE IF EXISTS `user_dialogs`;
  817. CREATE TABLE `user_dialogs` (
  818. `id` int(11) NOT NULL AUTO_INCREMENT,
  819. `user_id` int(11) NOT NULL,
  820. `peer_type` tinyint(4) NOT NULL,
  821. `peer_id` int(11) NOT NULL,
  822. `is_pinned` tinyint(4) NOT NULL DEFAULT '0',
  823. `top_message` int(11) NOT NULL DEFAULT '0',
  824. `read_inbox_max_id` int(11) NOT NULL DEFAULT '0',
  825. `read_outbox_max_id` int(11) NOT NULL DEFAULT '0',
  826. `unread_count` int(11) NOT NULL DEFAULT '0',
  827. `unread_mentions_count` int(11) NOT NULL DEFAULT '0',
  828. `show_previews` tinyint(4) NOT NULL DEFAULT '1',
  829. `silent` tinyint(4) NOT NULL DEFAULT '0',
  830. `mute_until` int(11) NOT NULL DEFAULT '0',
  831. `sound` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default',
  832. `pts` int(11) NOT NULL DEFAULT '0',
  833. `draft_id` int(11) NOT NULL DEFAULT '0',
  834. `draft_type` tinyint(4) NOT NULL DEFAULT '0',
  835. `draft_message_data` text COLLATE utf8mb4_unicode_ci NOT NULL,
  836. `date2` int(11) NOT NULL,
  837. `version` bigint(20) NOT NULL DEFAULT '0',
  838. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  839. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  840. PRIMARY KEY (`id`),
  841. UNIQUE KEY `user_id` (`user_id`,`peer_type`,`peer_id`)
  842. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  843. -- ----------------------------
  844. -- Table structure for user_notify_settings
  845. -- ----------------------------
  846. DROP TABLE IF EXISTS `user_notify_settings`;
  847. CREATE TABLE `user_notify_settings` (
  848. `id` int(11) NOT NULL AUTO_INCREMENT,
  849. `user_id` int(11) NOT NULL,
  850. `peer_type` tinyint(4) NOT NULL,
  851. `peer_id` int(11) NOT NULL,
  852. `show_previews` tinyint(1) NOT NULL DEFAULT '0',
  853. `silent` tinyint(1) NOT NULL DEFAULT '0',
  854. `mute_until` int(11) NOT NULL DEFAULT '0',
  855. `sound` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default',
  856. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  857. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  858. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  859. PRIMARY KEY (`id`),
  860. UNIQUE KEY `user_id` (`user_id`,`peer_type`,`peer_id`)
  861. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  862. -- ----------------------------
  863. -- Table structure for user_passwords
  864. -- ----------------------------
  865. DROP TABLE IF EXISTS `user_passwords`;
  866. CREATE TABLE `user_passwords` (
  867. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  868. `user_id` int(11) NOT NULL,
  869. `server_salt` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  870. `hash` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  871. `salt` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  872. `hint` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  873. `email` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  874. `has_recovery` tinyint(4) NOT NULL DEFAULT '0',
  875. `code` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  876. `code_expired` int(11) NOT NULL DEFAULT '0',
  877. `attempts` int(11) NOT NULL DEFAULT '0',
  878. `state` tinyint(4) NOT NULL DEFAULT '0',
  879. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  880. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  881. PRIMARY KEY (`id`),
  882. UNIQUE KEY `user_id` (`user_id`)
  883. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  884. -- ----------------------------
  885. -- Table structure for user_presences
  886. -- ----------------------------
  887. DROP TABLE IF EXISTS `user_presences`;
  888. CREATE TABLE `user_presences` (
  889. `id` int(11) NOT NULL AUTO_INCREMENT,
  890. `user_id` int(11) NOT NULL,
  891. `last_seen_at` bigint(20) NOT NULL,
  892. `last_seen_auth_key_id` bigint(20) NOT NULL,
  893. `last_seen_ip` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  894. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  895. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  896. PRIMARY KEY (`id`),
  897. UNIQUE KEY `user_id` (`user_id`),
  898. KEY `user_id_2` (`user_id`,`last_seen_at`)
  899. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  900. -- ----------------------------
  901. -- Table structure for user_privacys
  902. -- ----------------------------
  903. DROP TABLE IF EXISTS `user_privacys`;
  904. CREATE TABLE `user_privacys` (
  905. `id` int(11) NOT NULL AUTO_INCREMENT,
  906. `user_id` int(11) NOT NULL,
  907. `key_type` tinyint(4) NOT NULL DEFAULT '0',
  908. `rules` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  909. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  910. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  911. PRIMARY KEY (`id`),
  912. UNIQUE KEY `user_id` (`user_id`,`key_type`)
  913. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  914. -- ----------------------------
  915. -- Table structure for user_profile_photos
  916. -- ----------------------------
  917. DROP TABLE IF EXISTS `user_profile_photos`;
  918. CREATE TABLE `user_profile_photos` (
  919. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  920. `user_id` int(11) NOT NULL,
  921. `photo_id` bigint(20) NOT NULL,
  922. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  923. PRIMARY KEY (`id`)
  924. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  925. -- ----------------------------
  926. -- Table structure for user_pts_updates
  927. -- ----------------------------
  928. DROP TABLE IF EXISTS `user_pts_updates`;
  929. CREATE TABLE `user_pts_updates` (
  930. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  931. `user_id` int(11) NOT NULL,
  932. `pts` int(11) NOT NULL,
  933. `pts_count` int(11) NOT NULL,
  934. `update_type` tinyint(4) NOT NULL DEFAULT '0',
  935. `update_data` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  936. `date2` int(11) NOT NULL,
  937. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  938. PRIMARY KEY (`id`)
  939. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  940. -- ----------------------------
  941. -- Table structure for user_qts_updates
  942. -- ----------------------------
  943. DROP TABLE IF EXISTS `user_qts_updates`;
  944. CREATE TABLE `user_qts_updates` (
  945. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  946. `user_id` int(11) NOT NULL,
  947. `qts` int(11) NOT NULL,
  948. `update_type` int(11) NOT NULL,
  949. `update_data` blob NOT NULL,
  950. `date2` int(11) NOT NULL,
  951. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  952. PRIMARY KEY (`id`)
  953. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  954. -- ----------------------------
  955. -- Table structure for user_sticker_sets
  956. -- ----------------------------
  957. DROP TABLE IF EXISTS `user_sticker_sets`;
  958. CREATE TABLE `user_sticker_sets` (
  959. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  960. `user_id` int(11) NOT NULL DEFAULT '0',
  961. `sticker_set_id` bigint(20) NOT NULL DEFAULT '0',
  962. `archived` tinyint(4) NOT NULL DEFAULT '0',
  963. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  964. PRIMARY KEY (`id`),
  965. UNIQUE KEY `uniq` (`user_id`,`sticker_set_id`) USING BTREE,
  966. KEY `user_id` (`user_id`) USING BTREE
  967. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  968. -- ----------------------------
  969. -- Table structure for username
  970. -- ----------------------------
  971. DROP TABLE IF EXISTS `username`;
  972. CREATE TABLE `username` (
  973. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  974. `peer_type` tinyint(4) NOT NULL,
  975. `peer_id` int(11) NOT NULL,
  976. `username` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
  977. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  978. `update_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  979. PRIMARY KEY (`id`),
  980. UNIQUE KEY `peer_type` (`peer_type`,`peer_id`),
  981. KEY `username` (`username`)
  982. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  983. -- ----------------------------
  984. -- Table structure for users
  985. -- ----------------------------
  986. DROP TABLE IF EXISTS `users`;
  987. CREATE TABLE `users` (
  988. `id` int(11) NOT NULL AUTO_INCREMENT,
  989. `user_type` tinyint(4) NOT NULL DEFAULT '0',
  990. `access_hash` bigint(20) NOT NULL,
  991. `first_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  992. `last_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  993. `username` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  994. `phone` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  995. `country_code` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  996. `verified` tinyint(4) NOT NULL DEFAULT '0',
  997. `about` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  998. `state` int(11) NOT NULL DEFAULT '0',
  999. `is_bot` tinyint(1) NOT NULL DEFAULT '0',
  1000. `account_days_ttl` int(11) NOT NULL DEFAULT '180',
  1001. `photos` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  1002. `min` tinyint(4) NOT NULL DEFAULT '0',
  1003. `restricted` tinyint(4) NOT NULL DEFAULT '0',
  1004. `restriction_reason` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  1005. `deleted` tinyint(4) NOT NULL DEFAULT '0',
  1006. `delete_reason` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  1007. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  1008. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  1009. PRIMARY KEY (`id`)
  1010. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  1011. -- ----------------------------
  1012. -- Table structure for wall_papers
  1013. -- ----------------------------
  1014. DROP TABLE IF EXISTS `wall_papers`;
  1015. CREATE TABLE `wall_papers` (
  1016. `id` int(11) NOT NULL AUTO_INCREMENT,
  1017. `type` tinyint(4) NOT NULL DEFAULT '0',
  1018. `title` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  1019. `color` int(11) NOT NULL DEFAULT '0',
  1020. `bg_color` int(11) NOT NULL DEFAULT '0',
  1021. `photo_id` bigint(20) NOT NULL DEFAULT '0',
  1022. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  1023. `deleted_at` bigint(20) NOT NULL DEFAULT '0',
  1024. PRIMARY KEY (`id`)
  1025. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  1026. SET FOREIGN_KEY_CHECKS = 1;