create_db.sql 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  2. SET time_zone = "+00:00";
  3. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  4. /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  5. /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  6. /*!40101 SET NAMES utf8mb4 */;
  7. CREATE DATABASE IF NOT EXISTS `stat` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  8. USE `stat`;
  9. CREATE TABLE `acl` (
  10. `id` int(11) NOT NULL,
  11. `name` varchar(30) NOT NULL,
  12. `description.english` varchar(250) NOT NULL,
  13. `description.russian` varchar(250) NOT NULL
  14. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  15. CREATE TABLE `ad_comp_cache` (
  16. `id` int(11) NOT NULL,
  17. `name` varchar(63) NOT NULL,
  18. `last_found` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
  19. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  20. CREATE TABLE `auth_rules` (
  21. `id` int(11) NOT NULL,
  22. `user_id` int(11) DEFAULT NULL,
  23. `ou_id` int(11) DEFAULT NULL,
  24. `type` int(11) NOT NULL,
  25. `rule` varchar(40) DEFAULT NULL,
  26. `comment` varchar(250) DEFAULT NULL
  27. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  28. CREATE TABLE `building` (
  29. `id` int(11) NOT NULL,
  30. `name` varchar(50) NOT NULL,
  31. `comment` varchar(250) DEFAULT NULL
  32. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  33. CREATE TABLE `config` (
  34. `id` int(11) NOT NULL,
  35. `option_id` int(11) DEFAULT NULL,
  36. `value` varchar(250) DEFAULT NULL
  37. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  38. CREATE TABLE `config_options` (
  39. `id` int(11) NOT NULL,
  40. `option_name` varchar(50) NOT NULL,
  41. `description.russian` text DEFAULT NULL,
  42. `description.english` text DEFAULT NULL,
  43. `draft` tinyint(1) NOT NULL DEFAULT 0,
  44. `uniq` tinyint(1) NOT NULL DEFAULT 1,
  45. `type` varchar(100) NOT NULL,
  46. `default_value` varchar(250) DEFAULT NULL,
  47. `min_value` int(11) NOT NULL DEFAULT 0,
  48. `max_value` int(11) NOT NULL DEFAULT 0
  49. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  50. CREATE TABLE `connections` (
  51. `id` bigint(20) UNSIGNED NOT NULL,
  52. `device_id` bigint(20) UNSIGNED NOT NULL,
  53. `port_id` bigint(20) UNSIGNED NOT NULL,
  54. `auth_id` bigint(20) UNSIGNED NOT NULL,
  55. `last_found` datetime NOT NULL DEFAULT current_timestamp()
  56. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  57. CREATE TABLE `Customers` (
  58. `id` int(11) NOT NULL,
  59. `Login` varchar(20) DEFAULT 'NULL',
  60. `comment` varchar(100) DEFAULT NULL,
  61. `password` varchar(255) DEFAULT 'NULL',
  62. `api_key` varchar(255) DEFAULT NULL,
  63. `rights` tinyint(1) NOT NULL DEFAULT 3
  64. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  65. CREATE TABLE `devices` (
  66. `id` int(11) NOT NULL,
  67. `device_type` int(11) NOT NULL DEFAULT 1,
  68. `device_model_id` int(11) DEFAULT 89,
  69. `firmware` varchar(100) DEFAULT NULL,
  70. `vendor_id` int(11) NOT NULL DEFAULT 1,
  71. `device_name` varchar(50) DEFAULT NULL,
  72. `building_id` int(11) NOT NULL DEFAULT 1,
  73. `ip` varchar(15) DEFAULT NULL,
  74. `ip_int` bigint(10) UNSIGNED DEFAULT NULL,
  75. `login` varchar(50) DEFAULT NULL,
  76. `password` varchar(255) DEFAULT NULL,
  77. `protocol` int(11) NOT NULL DEFAULT 0,
  78. `control_port` int(11) NOT NULL DEFAULT 23,
  79. `port_count` int(11) NOT NULL DEFAULT 0,
  80. `SN` varchar(80) DEFAULT NULL,
  81. `comment` varchar(255) DEFAULT NULL,
  82. `snmp_version` tinyint(4) NOT NULL DEFAULT 0,
  83. `snmp3_auth_proto` varchar(10) NOT NULL DEFAULT 'sha512',
  84. `snmp3_priv_proto` varchar(10) NOT NULL DEFAULT 'aes128',
  85. `snmp3_user_rw` varchar(20) DEFAULT NULL,
  86. `snmp3_user_rw_password` varchar(20) DEFAULT NULL,
  87. `snmp3_user_ro` varchar(20) DEFAULT NULL,
  88. `snmp3_user_ro_password` varchar(20) DEFAULT NULL,
  89. `community` varchar(50) NOT NULL DEFAULT 'public',
  90. `rw_community` varchar(50) NOT NULL DEFAULT 'private',
  91. `fdb_snmp_index` tinyint(1) NOT NULL DEFAULT 0,
  92. `discovery` tinyint(1) NOT NULL DEFAULT 1,
  93. `netflow_save` tinyint(1) NOT NULL DEFAULT 0,
  94. `user_acl` tinyint(1) NOT NULL DEFAULT 0,
  95. `dhcp` tinyint(1) NOT NULL DEFAULT 0,
  96. `nagios` tinyint(1) NOT NULL DEFAULT 0,
  97. `active` tinyint(1) NOT NULL DEFAULT 1,
  98. `nagios_status` varchar(10) NOT NULL DEFAULT 'UP',
  99. `queue_enabled` tinyint(1) NOT NULL DEFAULT 0,
  100. `connected_user_only` tinyint(1) NOT NULL DEFAULT 1,
  101. `user_id` int(11) DEFAULT NULL,
  102. `deleted` tinyint(1) NOT NULL DEFAULT 0,
  103. `discovery_locked` tinyint(1) NOT NULL DEFAULT 0,
  104. `locked_timestamp` timestamp NULL DEFAULT current_timestamp()
  105. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  106. CREATE TABLE `device_filter_instances` (
  107. `id` int(11) NOT NULL,
  108. `instance_id` int(11) DEFAULT NULL,
  109. `device_id` int(11) DEFAULT NULL
  110. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  111. CREATE TABLE `device_l3_interfaces` (
  112. `id` int(11) NOT NULL,
  113. `device_id` int(11) DEFAULT NULL,
  114. `snmpin` int(11) DEFAULT NULL,
  115. `interface_type` int(11) NOT NULL DEFAULT 0,
  116. `name` varchar(100) DEFAULT NULL
  117. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  118. CREATE TABLE `device_models` (
  119. `id` int(11) NOT NULL,
  120. `model_name` varchar(200) DEFAULT NULL,
  121. `vendor_id` int(11) DEFAULT 1,
  122. `poe_in` tinyint(1) NOT NULL DEFAULT 0,
  123. `poe_out` tinyint(1) NOT NULL DEFAULT 0,
  124. `nagios_template` varchar(200) DEFAULT NULL
  125. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  126. CREATE TABLE `device_ports` (
  127. `id` bigint(20) UNSIGNED NOT NULL,
  128. `device_id` int(11) DEFAULT NULL,
  129. `snmp_index` int(11) DEFAULT NULL,
  130. `port` int(11) DEFAULT NULL,
  131. `ifName` varchar(40) DEFAULT NULL,
  132. `port_name` varchar(40) DEFAULT NULL,
  133. `comment` varchar(50) DEFAULT NULL,
  134. `target_port_id` int(11) NOT NULL DEFAULT 0,
  135. `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
  136. `last_mac_count` int(11) DEFAULT 0,
  137. `uplink` tinyint(1) NOT NULL DEFAULT 0,
  138. `nagios` tinyint(1) NOT NULL DEFAULT 0,
  139. `skip` tinyint(1) NOT NULL DEFAULT 0,
  140. `vlan` int(11) NOT NULL DEFAULT 1,
  141. `tagged_vlan` varchar(250) DEFAULT NULL,
  142. `untagged_vlan` varchar(250) DEFAULT NULL,
  143. `forbidden_vlan` varchar(250) DEFAULT NULL
  144. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  145. CREATE TABLE `device_types` (
  146. `id` int(11) NOT NULL,
  147. `name.russian` varchar(50) DEFAULT NULL,
  148. `name.english` varchar(50) DEFAULT NULL
  149. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  150. CREATE TABLE `dhcp_log` (
  151. `id` bigint(20) UNSIGNED NOT NULL,
  152. `mac` varchar(17) NOT NULL,
  153. `ip_int` bigint(20) UNSIGNED NOT NULL,
  154. `ip` varchar(15) NOT NULL,
  155. `action` varchar(10) NOT NULL,
  156. `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  157. `auth_id` bigint(20) UNSIGNED NOT NULL,
  158. `dhcp_hostname` varchar(250) DEFAULT NULL,
  159. `circuit-id` varchar(255) DEFAULT NULL,
  160. `remote-id` varchar(255) DEFAULT NULL,
  161. `client-id` varchar(250) DEFAULT NULL
  162. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
  163. CREATE TABLE `dhcp_queue` (
  164. `id` bigint(20) UNSIGNED NOT NULL,
  165. `mac` varchar(17) NOT NULL,
  166. `ip` varchar(15) NOT NULL,
  167. `action` varchar(10) NOT NULL,
  168. `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  169. `dhcp_hostname` varchar(250) DEFAULT NULL
  170. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
  171. CREATE TABLE `dns_cache` (
  172. `id` bigint(20) UNSIGNED NOT NULL,
  173. `dns` varchar(250) DEFAULT NULL,
  174. `ip` bigint(20) UNSIGNED DEFAULT NULL,
  175. `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
  176. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  177. CREATE TABLE `dns_queue` (
  178. `id` int(11) NOT NULL,
  179. `auth_id` int(11) DEFAULT NULL,
  180. `name_type` varchar(10) NOT NULL DEFAULT 'A',
  181. `name` varchar(200) DEFAULT NULL,
  182. `type` varchar(10) NOT NULL DEFAULT 'add',
  183. `value` varchar(100) DEFAULT NULL
  184. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  185. CREATE TABLE `filter_instances` (
  186. `id` int(11) NOT NULL,
  187. `name` varchar(50) DEFAULT NULL,
  188. `comment` varchar(200) DEFAULT NULL
  189. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  190. CREATE TABLE `Filter_list` (
  191. `id` int(11) NOT NULL,
  192. `name` varchar(50) DEFAULT NULL,
  193. `comment` varchar(250) DEFAULT NULL,
  194. `proto` varchar(10) DEFAULT NULL,
  195. `dst` text DEFAULT NULL,
  196. `dstport` varchar(20) DEFAULT NULL,
  197. `srcport` varchar(20) DEFAULT NULL,
  198. `type` int(10) UNSIGNED NOT NULL DEFAULT 0
  199. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  200. CREATE TABLE `gateway_subnets` (
  201. `id` int(11) NOT NULL,
  202. `device_id` int(11) DEFAULT NULL,
  203. `subnet_id` int(11) DEFAULT NULL
  204. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  205. CREATE TABLE `Group_filters` (
  206. `id` int(11) NOT NULL,
  207. `group_id` int(11) NOT NULL DEFAULT 0,
  208. `filter_id` int(11) NOT NULL DEFAULT 0,
  209. `order` int(11) NOT NULL DEFAULT 0,
  210. `action` tinyint(1) NOT NULL DEFAULT 0
  211. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  212. CREATE TABLE `Group_list` (
  213. `id` int(11) NOT NULL,
  214. `instance_id` int(11) NOT NULL DEFAULT 1,
  215. `group_name` varchar(50) DEFAULT NULL,
  216. `comment` varchar(250) DEFAULT NULL
  217. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  218. CREATE TABLE `mac_history` (
  219. `id` bigint(20) UNSIGNED NOT NULL,
  220. `mac` varchar(12) DEFAULT NULL,
  221. `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  222. `device_id` bigint(20) UNSIGNED DEFAULT NULL,
  223. `port_id` bigint(20) UNSIGNED DEFAULT NULL,
  224. `ip` varchar(16) NOT NULL DEFAULT '',
  225. `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
  226. `dhcp_hostname` varchar(250) DEFAULT NULL
  227. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  228. CREATE TABLE `mac_vendors` (
  229. `id` int(11) NOT NULL,
  230. `oui` varchar(20) DEFAULT NULL,
  231. `companyName` varchar(255) DEFAULT NULL,
  232. `companyAddress` varchar(255) DEFAULT NULL
  233. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  234. CREATE TABLE `OU` (
  235. `id` int(11) NOT NULL,
  236. `ou_name` varchar(40) DEFAULT NULL,
  237. `comment` varchar(250) DEFAULT NULL,
  238. `default_users` tinyint(1) NOT NULL DEFAULT 0,
  239. `default_hotspot` tinyint(1) NOT NULL DEFAULT 0,
  240. `nagios_dir` varchar(255) DEFAULT NULL,
  241. `nagios_host_use` varchar(50) DEFAULT NULL,
  242. `nagios_ping` tinyint(1) NOT NULL DEFAULT 1,
  243. `nagios_default_service` varchar(100) DEFAULT NULL,
  244. `enabled` int(11) NOT NULL DEFAULT 0,
  245. `filter_group_id` int(11) NOT NULL DEFAULT 0,
  246. `queue_id` int(11) NOT NULL DEFAULT 0,
  247. `dynamic` tinyint(1) NOT NULL DEFAULT 0,
  248. `life_duration` decimal(10,2) NOT NULL DEFAULT 24.00,
  249. `parent_id` int(11) DEFAULT NULL
  250. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  251. CREATE TABLE `Queue_list` (
  252. `id` int(11) NOT NULL,
  253. `queue_name` varchar(20) NOT NULL,
  254. `Download` int(11) NOT NULL DEFAULT 0,
  255. `Upload` int(11) NOT NULL DEFAULT 0
  256. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  257. CREATE TABLE `remote_syslog` (
  258. `id` bigint(20) UNSIGNED NOT NULL,
  259. `date` timestamp NOT NULL DEFAULT current_timestamp(),
  260. `device_id` bigint(20) UNSIGNED NOT NULL,
  261. `ip` varchar(15) NOT NULL,
  262. `message` text NOT NULL
  263. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
  264. CREATE TABLE `sessions` (
  265. `id` varchar(128) NOT NULL,
  266. `data` text NOT NULL,
  267. `last_accessed` int(11) NOT NULL
  268. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  269. CREATE TABLE `subnets` (
  270. `id` int(11) NOT NULL,
  271. `subnet` varchar(18) DEFAULT NULL,
  272. `vlan_tag` int(11) NOT NULL DEFAULT 1,
  273. `ip_int_start` bigint(20) NOT NULL,
  274. `ip_int_stop` bigint(20) NOT NULL,
  275. `dhcp_start` bigint(20) NOT NULL DEFAULT 0,
  276. `dhcp_stop` bigint(20) NOT NULL DEFAULT 0,
  277. `dhcp_lease_time` int(11) NOT NULL DEFAULT 480,
  278. `gateway` bigint(20) NOT NULL DEFAULT 0,
  279. `office` tinyint(1) NOT NULL DEFAULT 1,
  280. `hotspot` tinyint(1) NOT NULL DEFAULT 0,
  281. `vpn` tinyint(1) NOT NULL DEFAULT 0,
  282. `free` tinyint(1) NOT NULL DEFAULT 0,
  283. `dhcp` tinyint(1) NOT NULL DEFAULT 1,
  284. `static` tinyint(1) NOT NULL DEFAULT 0,
  285. `dhcp_update_hostname` tinyint(1) NOT NULL DEFAULT 0,
  286. `discovery` tinyint(1) NOT NULL DEFAULT 1,
  287. `notify` tinyint(1) NOT NULL DEFAULT 7,
  288. `comment` varchar(250) DEFAULT NULL
  289. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  290. CREATE TABLE `Traffic_detail` (
  291. `id` bigint(20) UNSIGNED NOT NULL,
  292. `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
  293. `router_id` int(11) NOT NULL DEFAULT 0,
  294. `timestamp` timestamp NULL DEFAULT NULL,
  295. `proto` tinyint(3) UNSIGNED DEFAULT NULL,
  296. `src_ip` int(10) UNSIGNED NOT NULL,
  297. `dst_ip` int(10) UNSIGNED NOT NULL,
  298. `src_port` smallint(5) UNSIGNED NOT NULL,
  299. `dst_port` smallint(5) UNSIGNED NOT NULL,
  300. `bytes` bigint(20) NOT NULL,
  301. `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
  302. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  303. CREATE TABLE `Unknown_mac` (
  304. `id` bigint(20) UNSIGNED NOT NULL,
  305. `mac` varchar(12) DEFAULT NULL,
  306. `port_id` bigint(20) UNSIGNED DEFAULT NULL,
  307. `device_id` int(11) DEFAULT NULL,
  308. `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
  309. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  310. CREATE TABLE `User_auth` (
  311. `id` int(11) NOT NULL,
  312. `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  313. `ou_id` int(11) DEFAULT NULL,
  314. `ip` varchar(18) NOT NULL DEFAULT '',
  315. `ip_int` bigint(10) UNSIGNED NOT NULL DEFAULT 0,
  316. `save_traf` tinyint(1) NOT NULL DEFAULT 0,
  317. `enabled` tinyint(1) NOT NULL DEFAULT 0,
  318. `dhcp` tinyint(1) NOT NULL DEFAULT 1,
  319. `filter_group_id` tinyint(1) NOT NULL DEFAULT 0,
  320. `dynamic` tinyint(1) NOT NULL DEFAULT 0,
  321. `eof` datetime DEFAULT NULL,
  322. `deleted` tinyint(4) NOT NULL DEFAULT 0,
  323. `comments` varchar(250) DEFAULT NULL,
  324. `dns_name` varchar(253) DEFAULT NULL,
  325. `dns_ptr_only` tinyint(1) NOT NULL DEFAULT 0,
  326. `WikiName` varchar(250) DEFAULT NULL,
  327. `dhcp_acl` text DEFAULT NULL,
  328. `queue_id` int(11) NOT NULL DEFAULT 0,
  329. `mac` varchar(20) NOT NULL DEFAULT '',
  330. `dhcp_action` varchar(10) NOT NULL DEFAULT '',
  331. `dhcp_option_set` varchar(50) DEFAULT NULL,
  332. `dhcp_time` datetime NOT NULL DEFAULT current_timestamp(),
  333. `dhcp_hostname` varchar(60) DEFAULT NULL,
  334. `last_found` datetime NOT NULL DEFAULT current_timestamp(),
  335. `arp_found` datetime DEFAULT NULL,
  336. `blocked` tinyint(1) NOT NULL DEFAULT 0,
  337. `day_quota` int(11) NOT NULL DEFAULT 0,
  338. `month_quota` int(11) NOT NULL DEFAULT 0,
  339. `device_model_id` int(11) DEFAULT 87,
  340. `firmware` varchar(100) DEFAULT NULL,
  341. `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  342. `client-id` varchar(250) DEFAULT NULL,
  343. `nagios` tinyint(1) NOT NULL DEFAULT 0,
  344. `nagios_status` varchar(10) NOT NULL DEFAULT '',
  345. `nagios_handler` varchar(50) NOT NULL DEFAULT '',
  346. `link_check` tinyint(1) NOT NULL DEFAULT 0,
  347. `changed` tinyint(1) NOT NULL DEFAULT 0,
  348. `dhcp_changed` int(11) NOT NULL DEFAULT 0,
  349. `changed_time` datetime NOT NULL DEFAULT current_timestamp(),
  350. `created_by` varchar(10) DEFAULT NULL
  351. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  352. CREATE TABLE `User_auth_alias` (
  353. `id` int(11) NOT NULL,
  354. `auth_id` int(11) NOT NULL,
  355. `alias` varchar(100) DEFAULT NULL,
  356. `description` varchar(100) DEFAULT NULL,
  357. `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
  358. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  359. CREATE TABLE `User_list` (
  360. `id` bigint(20) UNSIGNED NOT NULL,
  361. `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  362. `login` varchar(255) DEFAULT NULL,
  363. `fio` varchar(255) DEFAULT NULL,
  364. `enabled` tinyint(1) NOT NULL DEFAULT 1,
  365. `blocked` tinyint(1) NOT NULL DEFAULT 0,
  366. `deleted` tinyint(1) NOT NULL DEFAULT 0,
  367. `ou_id` int(11) NOT NULL DEFAULT 0,
  368. `device_id` int(11) DEFAULT NULL,
  369. `filter_group_id` int(11) NOT NULL DEFAULT 0,
  370. `queue_id` int(11) NOT NULL DEFAULT 0,
  371. `day_quota` int(11) NOT NULL DEFAULT 0,
  372. `month_quota` int(11) NOT NULL DEFAULT 0,
  373. `permanent` tinyint(1) NOT NULL DEFAULT 0
  374. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  375. CREATE TABLE `user_sessions` (
  376. `id` int(11) NOT NULL,
  377. `session_id` varchar(128) NOT NULL,
  378. `user_id` int(11) NOT NULL,
  379. `ip_address` varchar(45) NOT NULL,
  380. `user_agent` text NOT NULL,
  381. `created_at` int(11) NOT NULL,
  382. `last_activity` int(11) NOT NULL,
  383. `is_active` tinyint(1) DEFAULT 1
  384. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  385. CREATE TABLE `User_stats` (
  386. `id` bigint(20) UNSIGNED NOT NULL,
  387. `router_id` bigint(20) UNSIGNED DEFAULT 0,
  388. `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  389. `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  390. `byte_in` bigint(20) NOT NULL DEFAULT 0,
  391. `byte_out` bigint(20) NOT NULL DEFAULT 0
  392. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  393. CREATE TABLE `User_stats_full` (
  394. `id` bigint(20) UNSIGNED NOT NULL,
  395. `router_id` bigint(20) UNSIGNED DEFAULT 0,
  396. `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  397. `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  398. `byte_in` bigint(20) NOT NULL DEFAULT 0,
  399. `byte_out` bigint(20) NOT NULL DEFAULT 0,
  400. `pkt_in` int(11) DEFAULT NULL,
  401. `pkt_out` int(11) DEFAULT NULL,
  402. `step` int(11) NOT NULL DEFAULT 600
  403. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  404. CREATE TABLE `variables` (
  405. `id` int(11) NOT NULL,
  406. `name` varchar(30) NOT NULL,
  407. `value` varchar(255) DEFAULT NULL,
  408. `clear_time` timestamp NOT NULL DEFAULT current_timestamp(),
  409. `created` timestamp NOT NULL DEFAULT current_timestamp()
  410. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  411. CREATE TABLE `vendors` (
  412. `id` int(11) NOT NULL,
  413. `name` varchar(40) NOT NULL
  414. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  415. CREATE TABLE `version` (
  416. `id` int(11) NOT NULL DEFAULT 1,
  417. `version` varchar(10) NOT NULL DEFAULT '2.4.14'
  418. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  419. CREATE TABLE `Wan_stats` (
  420. `id` int(11) NOT NULL,
  421. `time` datetime NOT NULL DEFAULT current_timestamp(),
  422. `router_id` int(11) DEFAULT NULL,
  423. `interface_id` int(11) DEFAULT NULL,
  424. `in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  425. `out` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  426. `forward_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  427. `forward_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0
  428. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  429. CREATE TABLE `worklog` (
  430. `id` bigint(20) UNSIGNED NOT NULL,
  431. `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  432. `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  433. `customer` varchar(50) NOT NULL DEFAULT 'system',
  434. `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
  435. `message` text NOT NULL,
  436. `level` int(11) NOT NULL DEFAULT 1
  437. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
  438. ALTER TABLE `acl`
  439. ADD PRIMARY KEY (`id`);
  440. ALTER TABLE `ad_comp_cache`
  441. ADD PRIMARY KEY (`id`),
  442. ADD UNIQUE KEY `comp_name` (`name`);
  443. ALTER TABLE `auth_rules`
  444. ADD PRIMARY KEY (`id`),
  445. ADD UNIQUE KEY `rule` (`rule`),
  446. ADD KEY `user_id` (`user_id`);
  447. ALTER TABLE `building`
  448. ADD PRIMARY KEY (`id`);
  449. ALTER TABLE `config`
  450. ADD PRIMARY KEY (`id`),
  451. ADD KEY `option` (`option_id`);
  452. ALTER TABLE `config_options`
  453. ADD PRIMARY KEY (`id`);
  454. ALTER TABLE `connections`
  455. ADD PRIMARY KEY (`id`),
  456. ADD KEY `auth_id` (`auth_id`),
  457. ADD KEY `device_id` (`device_id`,`port_id`);
  458. ALTER TABLE `Customers`
  459. ADD PRIMARY KEY (`id`);
  460. ALTER TABLE `devices`
  461. ADD PRIMARY KEY (`id`),
  462. ADD KEY `ip` (`ip`),
  463. ADD KEY `device_type` (`device_type`);
  464. ALTER TABLE `device_filter_instances`
  465. ADD PRIMARY KEY (`id`);
  466. ALTER TABLE `device_l3_interfaces`
  467. ADD PRIMARY KEY (`id`);
  468. ALTER TABLE `device_models`
  469. ADD PRIMARY KEY (`id`);
  470. ALTER TABLE `device_ports`
  471. ADD PRIMARY KEY (`id`),
  472. ADD KEY `device_id` (`device_id`),
  473. ADD KEY `port` (`port`),
  474. ADD KEY `target_port_id` (`target_port_id`);
  475. ALTER TABLE `device_types`
  476. ADD PRIMARY KEY (`id`);
  477. ALTER TABLE `dhcp_log`
  478. ADD PRIMARY KEY (`id`),
  479. ADD KEY `timestamp` (`timestamp`,`action`);
  480. ALTER TABLE `dhcp_queue`
  481. ADD PRIMARY KEY (`id`),
  482. ADD KEY `timestamp` (`timestamp`,`action`);
  483. ALTER TABLE `dns_cache`
  484. ADD PRIMARY KEY (`id`),
  485. ADD KEY `dns` (`dns`,`ip`),
  486. ADD KEY `timestamp` (`timestamp`);
  487. ALTER TABLE `dns_queue`
  488. ADD PRIMARY KEY (`id`);
  489. ALTER TABLE `filter_instances`
  490. ADD PRIMARY KEY (`id`),
  491. ADD UNIQUE KEY `name` (`name`);
  492. ALTER TABLE `Filter_list`
  493. ADD PRIMARY KEY (`id`),
  494. ADD KEY `Name` (`name`);
  495. ALTER TABLE `gateway_subnets`
  496. ADD PRIMARY KEY (`id`);
  497. ALTER TABLE `Group_filters`
  498. ADD PRIMARY KEY (`id`),
  499. ADD KEY `GroupId` (`group_id`,`filter_id`);
  500. ALTER TABLE `Group_list`
  501. ADD PRIMARY KEY (`id`);
  502. ALTER TABLE `mac_history`
  503. ADD PRIMARY KEY (`id`),
  504. ADD KEY `mac` (`mac`,`timestamp`),
  505. ADD KEY `ip` (`ip`,`timestamp`),
  506. ADD KEY `timestamp` (`timestamp`) USING BTREE,
  507. ADD KEY `mac_2` (`mac`),
  508. ADD KEY `ip_2` (`ip`);
  509. ALTER TABLE `mac_vendors`
  510. ADD PRIMARY KEY (`id`),
  511. ADD KEY `oui` (`oui`);
  512. ALTER TABLE `OU`
  513. ADD PRIMARY KEY (`id`);
  514. ALTER TABLE `OU` ADD FULLTEXT KEY `ou_name` (`ou_name`);
  515. ALTER TABLE `OU` ADD FULLTEXT KEY `ou_name_2` (`ou_name`);
  516. ALTER TABLE `Queue_list`
  517. ADD PRIMARY KEY (`id`),
  518. ADD UNIQUE KEY `id` (`id`);
  519. ALTER TABLE `remote_syslog`
  520. ADD PRIMARY KEY (`id`),
  521. ADD KEY `date` (`date`,`device_id`,`ip`);
  522. ALTER TABLE `sessions`
  523. ADD PRIMARY KEY (`id`),
  524. ADD KEY `last_accessed` (`last_accessed`);
  525. ALTER TABLE `subnets`
  526. ADD PRIMARY KEY (`id`),
  527. ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
  528. ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
  529. ALTER TABLE `Traffic_detail`
  530. ADD PRIMARY KEY (`id`),
  531. ADD KEY `src` (`auth_id`,`timestamp`,`router_id`,`src_ip`) USING BTREE,
  532. ADD KEY `dst` (`auth_id`,`timestamp`,`router_id`,`dst_ip`) USING BTREE;
  533. ALTER TABLE `Unknown_mac`
  534. ADD PRIMARY KEY (`id`),
  535. ADD KEY `timestamp` (`timestamp`,`device_id`,`port_id`,`mac`);
  536. ALTER TABLE `User_auth`
  537. ADD PRIMARY KEY (`id`),
  538. ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
  539. ADD KEY `deleted` (`deleted`),
  540. ADD KEY `ou_id` (`ou_id`);
  541. ALTER TABLE `User_auth_alias`
  542. ADD PRIMARY KEY (`id`),
  543. ADD KEY `auth_id` (`auth_id`);
  544. ALTER TABLE `User_list`
  545. ADD PRIMARY KEY (`id`),
  546. ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
  547. ALTER TABLE `user_sessions`
  548. ADD PRIMARY KEY (`id`),
  549. ADD KEY `session_id` (`session_id`),
  550. ADD KEY `user_id` (`user_id`),
  551. ADD KEY `is_active` (`is_active`);
  552. ALTER TABLE `User_stats`
  553. ADD PRIMARY KEY (`id`),
  554. ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
  555. ALTER TABLE `User_stats_full`
  556. ADD PRIMARY KEY (`id`),
  557. ADD KEY `timestamp` (`timestamp`,`auth_id`,`router_id`);
  558. ALTER TABLE `variables`
  559. ADD PRIMARY KEY (`id`),
  560. ADD UNIQUE KEY `name` (`name`),
  561. ADD KEY `clear_time` (`clear_time`,`created`);
  562. ALTER TABLE `vendors`
  563. ADD PRIMARY KEY (`id`);
  564. ALTER TABLE `version`
  565. ADD UNIQUE KEY `id` (`id`);
  566. ALTER TABLE `Wan_stats`
  567. ADD PRIMARY KEY (`id`),
  568. ADD UNIQUE KEY `main` (`time`,`router_id`,`interface_id`),
  569. ADD KEY `times` (`time`);
  570. ALTER TABLE `worklog`
  571. ADD PRIMARY KEY (`id`),
  572. ADD KEY `idx_customer` (`customer`,`level`,`timestamp`),
  573. ADD KEY `idx_timestamp` (`level`,`timestamp`),
  574. ADD KEY `idx_auth_id` (`auth_id`,`level`,`timestamp`);
  575. ALTER TABLE `acl`
  576. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  577. ALTER TABLE `ad_comp_cache`
  578. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  579. ALTER TABLE `auth_rules`
  580. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  581. ALTER TABLE `building`
  582. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  583. ALTER TABLE `config`
  584. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  585. ALTER TABLE `config_options`
  586. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  587. ALTER TABLE `connections`
  588. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  589. ALTER TABLE `Customers`
  590. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  591. ALTER TABLE `devices`
  592. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  593. ALTER TABLE `device_filter_instances`
  594. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  595. ALTER TABLE `device_l3_interfaces`
  596. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  597. ALTER TABLE `device_models`
  598. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  599. ALTER TABLE `device_ports`
  600. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  601. ALTER TABLE `device_types`
  602. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  603. ALTER TABLE `dhcp_log`
  604. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  605. ALTER TABLE `dhcp_queue`
  606. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  607. ALTER TABLE `dns_cache`
  608. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  609. ALTER TABLE `dns_queue`
  610. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  611. ALTER TABLE `filter_instances`
  612. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  613. ALTER TABLE `Filter_list`
  614. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  615. ALTER TABLE `gateway_subnets`
  616. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  617. ALTER TABLE `Group_filters`
  618. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  619. ALTER TABLE `Group_list`
  620. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  621. ALTER TABLE `mac_history`
  622. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  623. ALTER TABLE `mac_vendors`
  624. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  625. ALTER TABLE `OU`
  626. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  627. ALTER TABLE `Queue_list`
  628. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  629. ALTER TABLE `remote_syslog`
  630. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  631. ALTER TABLE `subnets`
  632. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  633. ALTER TABLE `Traffic_detail`
  634. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  635. ALTER TABLE `Unknown_mac`
  636. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  637. ALTER TABLE `User_auth`
  638. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  639. ALTER TABLE `User_auth_alias`
  640. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  641. ALTER TABLE `User_list`
  642. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  643. ALTER TABLE `user_sessions`
  644. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  645. ALTER TABLE `User_stats`
  646. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  647. ALTER TABLE `User_stats_full`
  648. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  649. ALTER TABLE `variables`
  650. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  651. ALTER TABLE `vendors`
  652. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  653. ALTER TABLE `Wan_stats`
  654. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  655. ALTER TABLE `worklog`
  656. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  657. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  658. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  659. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;