Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.39 KB | None | 0 0
  1. -- --------------------------------------------------------
  2.  
  3. --
  4. -- Структура таблицы `gammu`
  5. --
  6.  
  7. CREATE TABLE `gammu` (
  8. `Version` int(11) NOT NULL DEFAULT '0'
  9. ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
  10.  
  11. --
  12. -- Дамп данных таблицы `gammu`
  13. --
  14.  
  15. INSERT INTO `gammu` (`Version`) VALUES
  16. (16);
  17.  
  18. -- --------------------------------------------------------
  19.  
  20. --
  21. -- Структура таблицы `inbox`
  22. --
  23.  
  24. CREATE TABLE `inbox` (
  25. `UpdatedInDB` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  26. `ReceivingDateTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  27. `Text` text NOT NULL,
  28. `SenderNumber` varchar(20) NOT NULL DEFAULT '',
  29. `Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL DEFAULT 'Default_No_Compression',
  30. `UDH` text NOT NULL,
  31. `SMSCNumber` varchar(20) NOT NULL DEFAULT '',
  32. `Class` int(11) NOT NULL DEFAULT '-1',
  33. `TextDecoded` text NOT NULL,
  34. `ID` int(10) UNSIGNED NOT NULL,
  35. `RecipientID` text NOT NULL,
  36. `Processed` enum('false','true') NOT NULL DEFAULT 'false'
  37. ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
  38.  
  39.  
  40.  
  41. --
  42. -- Триггеры `inbox`
  43. --
  44. DELIMITER $$
  45. CREATE TRIGGER `inbox_timestamp` BEFORE INSERT ON `inbox` FOR EACH ROW BEGIN
  46. IF NEW.ReceivingDateTime = '0000-00-00 00:00:00' THEN
  47. SET NEW.ReceivingDateTime = CURRENT_TIMESTAMP();
  48. END IF;
  49. END
  50. $$
  51. DELIMITER ;
  52.  
  53. -- --------------------------------------------------------
  54.  
  55. --
  56. -- Структура таблицы `outbox`
  57. --
  58.  
  59. CREATE TABLE `outbox` (
  60. `UpdatedInDB` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  61. `InsertIntoDB` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  62. `SendingDateTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  63. `SendBefore` time NOT NULL DEFAULT '23:59:59',
  64. `SendAfter` time NOT NULL DEFAULT '00:00:00',
  65. `Text` text,
  66. `DestinationNumber` varchar(20) NOT NULL DEFAULT '',
  67. `Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL DEFAULT 'Default_No_Compression',
  68. `UDH` text,
  69. `Class` int(11) DEFAULT '-1',
  70. `TextDecoded` text NOT NULL,
  71. `ID` int(10) UNSIGNED NOT NULL,
  72. `MultiPart` enum('false','true') DEFAULT 'false',
  73. `RelativeValidity` int(11) DEFAULT '-1',
  74. `SenderID` varchar(255) DEFAULT NULL,
  75. `SendingTimeOut` timestamp NULL DEFAULT '0000-00-00 00:00:00',
  76. `DeliveryReport` enum('default','yes','no') DEFAULT 'default',
  77. `CreatorID` text NOT NULL,
  78. `Retries` int(3) DEFAULT '0',
  79. `Priority` int(11) DEFAULT '0'
  80. ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
  81.  
  82. --
  83. -- Триггеры `outbox`
  84. --
  85. DELIMITER $$
  86. CREATE TRIGGER `outbox_timestamp` BEFORE INSERT ON `outbox` FOR EACH ROW BEGIN
  87. IF NEW.InsertIntoDB = '0000-00-00 00:00:00' THEN
  88. SET NEW.InsertIntoDB = CURRENT_TIMESTAMP();
  89. END IF;
  90. IF NEW.SendingDateTime = '0000-00-00 00:00:00' THEN
  91. SET NEW.SendingDateTime = CURRENT_TIMESTAMP();
  92. END IF;
  93. IF NEW.SendingTimeOut = '0000-00-00 00:00:00' THEN
  94. SET NEW.SendingTimeOut = CURRENT_TIMESTAMP();
  95. END IF;
  96. END
  97. $$
  98. DELIMITER ;
  99.  
  100. -- --------------------------------------------------------
  101.  
  102. --
  103. -- Структура таблицы `outbox_multipart`
  104. --
  105.  
  106. CREATE TABLE `outbox_multipart` (
  107. `Text` text,
  108. `Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL DEFAULT 'Default_No_Compression',
  109. `UDH` text,
  110. `Class` int(11) DEFAULT '-1',
  111. `TextDecoded` text,
  112. `ID` int(10) UNSIGNED NOT NULL DEFAULT '0',
  113. `SequencePosition` int(11) NOT NULL DEFAULT '1'
  114. ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
  115.  
  116. -- --------------------------------------------------------
  117.  
  118. --
  119. -- Структура таблицы `phones`
  120. --
  121.  
  122. CREATE TABLE `phones` (
  123. `ID` text NOT NULL,
  124. `UpdatedInDB` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  125. `InsertIntoDB` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  126. `TimeOut` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  127. `Send` enum('yes','no') NOT NULL DEFAULT 'no',
  128. `Receive` enum('yes','no') NOT NULL DEFAULT 'no',
  129. `IMEI` varchar(35) NOT NULL,
  130. `IMSI` varchar(35) NOT NULL,
  131. `NetCode` varchar(10) DEFAULT 'ERROR',
  132. `NetName` varchar(35) DEFAULT 'ERROR',
  133. `Client` text NOT NULL,
  134. `Battery` int(11) NOT NULL DEFAULT '-1',
  135. `Signal` int(11) NOT NULL DEFAULT '-1',
  136. `Sent` int(11) NOT NULL DEFAULT '0',
  137. `Received` int(11) NOT NULL DEFAULT '0'
  138. ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
  139.  
  140. --
  141. -- Дамп данных таблицы `phones`
  142. --
  143.  
  144.  
  145. --
  146. -- Триггеры `phones`
  147. --
  148. DELIMITER $$
  149. CREATE TRIGGER `phones_timestamp` BEFORE INSERT ON `phones` FOR EACH ROW BEGIN
  150. IF NEW.InsertIntoDB = '0000-00-00 00:00:00' THEN
  151. SET NEW.InsertIntoDB = CURRENT_TIMESTAMP();
  152. END IF;
  153. IF NEW.TimeOut = '0000-00-00 00:00:00' THEN
  154. SET NEW.TimeOut = CURRENT_TIMESTAMP();
  155. END IF;
  156. END
  157. $$
  158. DELIMITER ;
  159.  
  160. -- --------------------------------------------------------
  161.  
  162. --
  163. -- Структура таблицы `sentitems`
  164. --
  165.  
  166. CREATE TABLE `sentitems` (
  167. `UpdatedInDB` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  168. `InsertIntoDB` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  169. `SendingDateTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  170. `DeliveryDateTime` timestamp NULL DEFAULT NULL,
  171. `Text` text NOT NULL,
  172. `DestinationNumber` varchar(20) NOT NULL DEFAULT '',
  173. `Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL DEFAULT 'Default_No_Compression',
  174. `UDH` text NOT NULL,
  175. `SMSCNumber` varchar(20) NOT NULL DEFAULT '',
  176. `Class` int(11) NOT NULL DEFAULT '-1',
  177. `TextDecoded` text NOT NULL,
  178. `ID` int(10) UNSIGNED NOT NULL DEFAULT '0',
  179. `SenderID` varchar(255) NOT NULL,
  180. `SequencePosition` int(11) NOT NULL DEFAULT '1',
  181. `Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error') NOT NULL DEFAULT 'SendingOK',
  182. `StatusError` int(11) NOT NULL DEFAULT '-1',
  183. `TPMR` int(11) NOT NULL DEFAULT '-1',
  184. `RelativeValidity` int(11) NOT NULL DEFAULT '-1',
  185. `CreatorID` text NOT NULL
  186. ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
  187.  
  188.  
  189.  
  190.  
  191. --
  192. -- Триггеры `sentitems`
  193. --
  194. DELIMITER $$
  195. CREATE TRIGGER `sentitems_timestamp` BEFORE INSERT ON `sentitems` FOR EACH ROW BEGIN
  196. IF NEW.InsertIntoDB = '0000-00-00 00:00:00' THEN
  197. SET NEW.InsertIntoDB = CURRENT_TIMESTAMP();
  198. END IF;
  199. IF NEW.SendingDateTime = '0000-00-00 00:00:00' THEN
  200. SET NEW.SendingDateTime = CURRENT_TIMESTAMP();
  201. END IF;
  202. END
  203. $$
  204. DELIMITER ;
  205.  
  206. --
  207. -- Индексы сохранённых таблиц
  208. --
  209.  
  210. --
  211. -- Индексы таблицы `gammu`
  212. --
  213. ALTER TABLE `gammu`
  214. ADD PRIMARY KEY (`Version`);
  215.  
  216. --
  217. -- Индексы таблицы `inbox`
  218. --
  219. ALTER TABLE `inbox`
  220. ADD PRIMARY KEY (`ID`);
  221.  
  222. --
  223. -- Индексы таблицы `outbox`
  224. --
  225. ALTER TABLE `outbox`
  226. ADD PRIMARY KEY (`ID`),
  227. ADD KEY `outbox_date` (`SendingDateTime`,`SendingTimeOut`),
  228. ADD KEY `outbox_sender` (`SenderID`(250));
  229.  
  230. --
  231. -- Индексы таблицы `outbox_multipart`
  232. --
  233. ALTER TABLE `outbox_multipart`
  234. ADD PRIMARY KEY (`ID`,`SequencePosition`);
  235.  
  236. --
  237. -- Индексы таблицы `phones`
  238. --
  239. ALTER TABLE `phones`
  240. ADD PRIMARY KEY (`IMEI`);
  241.  
  242. --
  243. -- Индексы таблицы `sentitems`
  244. --
  245. ALTER TABLE `sentitems`
  246. ADD PRIMARY KEY (`ID`,`SequencePosition`),
  247. ADD KEY `sentitems_date` (`DeliveryDateTime`),
  248. ADD KEY `sentitems_tpmr` (`TPMR`),
  249. ADD KEY `sentitems_dest` (`DestinationNumber`),
  250. ADD KEY `sentitems_sender` (`SenderID`(250));
  251.  
  252. --
  253. -- AUTO_INCREMENT для сохранённых таблиц
  254. --
  255.  
  256. --
  257. -- AUTO_INCREMENT для таблицы `inbox`
  258. --
  259. ALTER TABLE `inbox`
  260. MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=30;
  261. --
  262. -- AUTO_INCREMENT для таблицы `outbox`
  263. --
  264. ALTER TABLE `outbox`
  265. MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement