1
0

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