create_db.sql 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  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` DATETIME 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` DATETIME 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. `bandwidth` int(11) DEFAULT NULL
  116. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  117. CREATE TABLE `device_models` (
  118. `id` int(11) NOT NULL,
  119. `model_name` varchar(200) DEFAULT NULL,
  120. `vendor_id` int(11) DEFAULT 1,
  121. `poe_in` tinyint(1) NOT NULL DEFAULT 0,
  122. `poe_out` tinyint(1) NOT NULL DEFAULT 0,
  123. `nagios_template` varchar(200) DEFAULT NULL
  124. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  125. CREATE TABLE `device_ports` (
  126. `id` bigint(20) UNSIGNED NOT NULL,
  127. `device_id` int(11) DEFAULT NULL,
  128. `snmp_index` int(11) DEFAULT NULL,
  129. `port` int(11) DEFAULT NULL,
  130. `ifname` varchar(40) DEFAULT NULL,
  131. `port_name` varchar(40) DEFAULT NULL,
  132. `description` varchar(50) DEFAULT NULL,
  133. `target_port_id` int(11) NOT NULL DEFAULT 0,
  134. `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
  135. `last_mac_count` int(11) DEFAULT 0,
  136. `uplink` tinyint(1) NOT NULL DEFAULT 0,
  137. `nagios` tinyint(1) NOT NULL DEFAULT 0,
  138. `skip` tinyint(1) NOT NULL DEFAULT 0,
  139. `vlan` int(11) NOT NULL DEFAULT 1,
  140. `tagged_vlan` varchar(250) DEFAULT NULL,
  141. `untagged_vlan` varchar(250) DEFAULT NULL,
  142. `forbidden_vlan` varchar(250) DEFAULT NULL
  143. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  144. CREATE TABLE `device_types` (
  145. `id` int(11) NOT NULL,
  146. name_russian varchar(50) DEFAULT NULL,
  147. name_english varchar(50) DEFAULT NULL
  148. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  149. CREATE TABLE `dhcp_log` (
  150. `id` bigint(20) UNSIGNED NOT NULL,
  151. `mac` varchar(17) NOT NULL,
  152. `ip_int` bigint(20) UNSIGNED NOT NULL,
  153. `ip` varchar(15) DEFAULT NULL,
  154. `action` varchar(10) NOT NULL,
  155. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  156. `auth_id` bigint(20) UNSIGNED NOT NULL,
  157. `dhcp_hostname` varchar(250) DEFAULT NULL,
  158. `circuit_id` varchar(255) DEFAULT NULL,
  159. `remote_id` varchar(255) DEFAULT NULL,
  160. `client_id` varchar(250) DEFAULT NULL
  161. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
  162. CREATE TABLE `dhcp_queue` (
  163. `id` bigint(20) UNSIGNED NOT NULL,
  164. `mac` varchar(17) NOT NULL,
  165. `ip` varchar(15) DEFAULT NULL,
  166. `action` varchar(10) NOT NULL,
  167. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  168. `dhcp_hostname` varchar(250) DEFAULT NULL
  169. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
  170. CREATE TABLE `dns_cache` (
  171. `id` bigint(20) UNSIGNED NOT NULL,
  172. `dns` varchar(250) DEFAULT NULL,
  173. `ip` bigint(20) UNSIGNED DEFAULT NULL,
  174. `ts` DATETIME NOT NULL DEFAULT current_timestamp()
  175. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  176. CREATE TABLE `dns_queue` (
  177. `id` int(11) NOT NULL,
  178. `auth_id` int(11) DEFAULT NULL,
  179. `name_type` varchar(10) NOT NULL DEFAULT 'A',
  180. `name` varchar(200) DEFAULT NULL,
  181. `operation_type` varchar(10) NOT NULL DEFAULT 'add',
  182. `value` varchar(100) DEFAULT NULL
  183. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  184. CREATE TABLE `filter_instances` (
  185. `id` int(11) NOT NULL,
  186. `name` varchar(50) DEFAULT NULL,
  187. `description` varchar(200) DEFAULT NULL
  188. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  189. CREATE TABLE `filter_list` (
  190. `id` int(11) NOT NULL,
  191. `name` varchar(50) DEFAULT NULL,
  192. `description` varchar(250) DEFAULT NULL,
  193. `proto` varchar(10) DEFAULT NULL,
  194. `dst` text DEFAULT NULL,
  195. `ipset_id` INT(11) DEFAULT NULL,
  196. `dstport` varchar(20) DEFAULT NULL,
  197. `srcport` varchar(20) DEFAULT NULL,
  198. `filter_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. `rule_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. `description` 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(17) DEFAULT NULL,
  221. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  222. `device_id` bigint(20) UNSIGNED DEFAULT NULL,
  223. `port_id` bigint(20) UNSIGNED DEFAULT NULL,
  224. `ip` varchar(15) DEFAULT NULL,
  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. `description` 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. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  260. `device_id` bigint(20) UNSIGNED NOT NULL,
  261. `ip` varchar(15) DEFAULT 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. `description` 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. `ts` DATETIME NULL DEFAULT NULL,
  295. `proto` tinyint(3) UNSIGNED DEFAULT NULL,
  296. `src_ip` bigint(20) NOT NULL DEFAULT 0,
  297. `dst_ip` bigint(20) NOT NULL DEFAULT 0,
  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(17) DEFAULT NULL,
  306. `port_id` bigint(20) UNSIGNED DEFAULT NULL,
  307. `device_id` int(11) DEFAULT NULL,
  308. `ts` DATETIME 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) DEFAULT NULL,
  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. `end_life` datetime DEFAULT NULL,
  322. `deleted` tinyint(4) NOT NULL DEFAULT 0,
  323. `description` 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(17) DEFAULT NULL,
  330. `dhcp_action` varchar(10) NOT NULL DEFAULT '',
  331. `dhcp_option_set` varchar(50) DEFAULT NULL,
  332. `dhcp_time` datetime DEFAULT NULL,
  333. `dhcp_hostname` varchar(60) DEFAULT NULL,
  334. `last_found` datetime NOT NULL DEFAULT current_timestamp(),
  335. `arp_found` datetime DEFAULT NULL,
  336. `mac_found` datetime DEFAULT NULL,
  337. `blocked` tinyint(1) NOT NULL DEFAULT 0,
  338. `day_quota` int(11) NOT NULL DEFAULT 0,
  339. `month_quota` int(11) NOT NULL DEFAULT 0,
  340. `device_model_id` int(11) DEFAULT 87,
  341. `firmware` varchar(100) DEFAULT NULL,
  342. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  343. `client_id` varchar(250) DEFAULT NULL,
  344. `nagios` tinyint(1) NOT NULL DEFAULT 0,
  345. `nagios_status` varchar(10) NOT NULL DEFAULT '',
  346. `nagios_handler` varchar(50) NOT NULL DEFAULT '',
  347. `link_check` tinyint(1) NOT NULL DEFAULT 0,
  348. `changed` tinyint(1) NOT NULL DEFAULT 0,
  349. `dhcp_changed` int(11) NOT NULL DEFAULT 0,
  350. `changed_time` datetime NOT NULL DEFAULT current_timestamp(),
  351. `created_by` varchar(10) DEFAULT NULL
  352. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  353. CREATE TABLE `user_auth_alias` (
  354. `id` int(11) NOT NULL,
  355. `auth_id` int(11) NOT NULL,
  356. `alias` varchar(100) DEFAULT NULL,
  357. `description` varchar(100) DEFAULT NULL,
  358. `ts` DATETIME NOT NULL DEFAULT current_timestamp()
  359. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  360. CREATE TABLE `user_list` (
  361. `id` bigint(20) UNSIGNED NOT NULL,
  362. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  363. `login` varchar(255) DEFAULT NULL,
  364. `description` varchar(255) DEFAULT NULL,
  365. `enabled` tinyint(1) NOT NULL DEFAULT 1,
  366. `blocked` tinyint(1) NOT NULL DEFAULT 0,
  367. `deleted` tinyint(1) NOT NULL DEFAULT 0,
  368. `ou_id` int(11) NOT NULL DEFAULT 0,
  369. `device_id` int(11) DEFAULT NULL,
  370. `filter_group_id` int(11) NOT NULL DEFAULT 0,
  371. `queue_id` int(11) NOT NULL DEFAULT 0,
  372. `day_quota` int(11) NOT NULL DEFAULT 0,
  373. `month_quota` int(11) NOT NULL DEFAULT 0,
  374. `permanent` tinyint(1) NOT NULL DEFAULT 0
  375. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  376. CREATE TABLE `user_sessions` (
  377. `id` int(11) NOT NULL,
  378. `session_id` varchar(128) NOT NULL,
  379. `user_id` int(11) NOT NULL,
  380. `ip_address` varchar(45) NOT NULL,
  381. `user_agent` text NOT NULL,
  382. `created_at` int(11) NOT NULL,
  383. `last_activity` int(11) NOT NULL,
  384. `is_active` tinyint(1) DEFAULT 1
  385. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  386. CREATE TABLE `user_stats` (
  387. `id` bigint(20) UNSIGNED NOT NULL,
  388. `router_id` bigint(20) UNSIGNED DEFAULT 0,
  389. `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  390. `ts` datetime NOT NULL DEFAULT current_timestamp(),
  391. `byte_in` bigint(20) NOT NULL DEFAULT 0,
  392. `byte_out` bigint(20) NOT NULL DEFAULT 0,
  393. `pkt_in` int(11) NOT NULL DEFAULT 0,
  394. `pkt_out` int(11) NOT NULL DEFAULT 0,
  395. `step` int(11) NOT NULL DEFAULT 3600
  396. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  397. CREATE TABLE `user_stats_full` (
  398. `id` bigint(20) UNSIGNED NOT NULL,
  399. `router_id` bigint(20) UNSIGNED DEFAULT 0,
  400. `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  401. `ts` datetime NOT NULL DEFAULT current_timestamp(),
  402. `byte_in` bigint(20) NOT NULL DEFAULT 0,
  403. `byte_out` bigint(20) NOT NULL DEFAULT 0,
  404. `pkt_in` int(11) NOT NULL DEFAULT 0,
  405. `pkt_out` int(11) NOT NULL DEFAULT 0,
  406. `step` int(11) NOT NULL DEFAULT 600
  407. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  408. CREATE TABLE `variables` (
  409. `id` int(11) NOT NULL,
  410. `name` varchar(30) NOT NULL,
  411. `value` varchar(255) DEFAULT NULL,
  412. `clear_time` DATETIME NOT NULL DEFAULT current_timestamp(),
  413. `created` DATETIME NOT NULL DEFAULT current_timestamp()
  414. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  415. CREATE TABLE `vendors` (
  416. `id` int(11) NOT NULL,
  417. `name` varchar(40) NOT NULL
  418. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  419. CREATE TABLE `version` (
  420. `id` int(11) NOT NULL DEFAULT 1,
  421. `version` varchar(10) NOT NULL DEFAULT '2.4.14'
  422. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  423. CREATE TABLE `wan_stats` (
  424. `id` int(11) NOT NULL,
  425. `ts` datetime NOT NULL DEFAULT current_timestamp(),
  426. `router_id` int(11) DEFAULT NULL,
  427. `interface_id` int(11) DEFAULT NULL,
  428. `bytes_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  429. `bytes_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  430. `forward_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  431. `forward_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0
  432. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  433. CREATE TABLE `worklog` (
  434. `id` bigint(20) UNSIGNED NOT NULL,
  435. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  436. `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  437. `customer` varchar(50) NOT NULL DEFAULT 'system',
  438. `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
  439. `message` text NOT NULL,
  440. `level` int(11) NOT NULL DEFAULT 1
  441. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
  442. CREATE TABLE `ipset_list` (
  443. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  444. `name` VARCHAR(64) NOT NULL UNIQUE COMMENT 'ipset name',
  445. `description` VARCHAR(255) DEFAULT NULL,
  446. `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  447. `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  448. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  449. CREATE TABLE `ipset_members` (
  450. `id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  451. `ipset_id` INT NOT NULL,
  452. `ip` VARCHAR(39) NOT NULL COMMENT 'IPv4 or IPv6 address',
  453. `description` VARCHAR(255) DEFAULT NULL,
  454. `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  455. UNIQUE KEY `uniq_ipset_ip` (`ipset_id`, `ip`),
  456. CONSTRAINT `fk_ipset_members_ipset`
  457. FOREIGN KEY (`ipset_id`) REFERENCES `ipset_list` (`id`) ON DELETE CASCADE
  458. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  459. ALTER TABLE `acl`
  460. ADD PRIMARY KEY (`id`);
  461. ALTER TABLE `ad_comp_cache`
  462. ADD PRIMARY KEY (`id`),
  463. ADD UNIQUE KEY `comp_name` (`name`);
  464. ALTER TABLE `auth_rules`
  465. ADD PRIMARY KEY (`id`),
  466. ADD UNIQUE KEY `rule` (`rule`),
  467. ADD KEY `user_id` (`user_id`);
  468. ALTER TABLE `building`
  469. ADD PRIMARY KEY (`id`);
  470. ALTER TABLE `config`
  471. ADD PRIMARY KEY (`id`),
  472. ADD KEY `option` (`option_id`);
  473. ALTER TABLE `config_options`
  474. ADD PRIMARY KEY (`id`);
  475. ALTER TABLE `connections`
  476. ADD PRIMARY KEY (`id`),
  477. ADD KEY `auth_id` (`auth_id`),
  478. ADD KEY `device_id` (`device_id`,`port_id`);
  479. ALTER TABLE `customers`
  480. ADD PRIMARY KEY (`id`);
  481. ALTER TABLE `devices`
  482. ADD PRIMARY KEY (`id`),
  483. ADD KEY `ip` (`ip`),
  484. ADD KEY `device_type` (`device_type`);
  485. ALTER TABLE `device_filter_instances`
  486. ADD PRIMARY KEY (`id`);
  487. ALTER TABLE `device_l3_interfaces`
  488. ADD PRIMARY KEY (`id`);
  489. ALTER TABLE `device_models`
  490. ADD PRIMARY KEY (`id`);
  491. ALTER TABLE `device_ports`
  492. ADD PRIMARY KEY (`id`),
  493. ADD KEY `device_id` (`device_id`),
  494. ADD KEY `port` (`port`),
  495. ADD KEY `target_port_id` (`target_port_id`);
  496. ALTER TABLE `device_types`
  497. ADD PRIMARY KEY (`id`);
  498. ALTER TABLE `dhcp_log`
  499. ADD PRIMARY KEY (`id`),
  500. ADD KEY `ts` (`ts`,`action`);
  501. ALTER TABLE `dhcp_queue`
  502. ADD PRIMARY KEY (`id`),
  503. ADD KEY `ts` (`ts`,`action`);
  504. ALTER TABLE `dns_cache`
  505. ADD PRIMARY KEY (`id`),
  506. ADD KEY `dns` (`dns`,`ip`),
  507. ADD KEY `ts` (`ts`);
  508. ALTER TABLE `dns_queue`
  509. ADD PRIMARY KEY (`id`);
  510. ALTER TABLE `filter_instances`
  511. ADD PRIMARY KEY (`id`),
  512. ADD UNIQUE KEY `name` (`name`);
  513. ALTER TABLE `filter_list`
  514. ADD PRIMARY KEY (`id`),
  515. ADD KEY `Name` (`name`);
  516. ALTER TABLE `gateway_subnets`
  517. ADD PRIMARY KEY (`id`);
  518. ALTER TABLE `group_filters`
  519. ADD PRIMARY KEY (`id`),
  520. ADD KEY `GroupId` (`group_id`,`filter_id`);
  521. ALTER TABLE `group_list`
  522. ADD PRIMARY KEY (`id`);
  523. ALTER TABLE `mac_history`
  524. ADD PRIMARY KEY (`id`),
  525. ADD KEY `mac` (`mac`,`ts`),
  526. ADD KEY `ip` (`ip`,`ts`),
  527. ADD KEY `ts` (`ts`) USING BTREE,
  528. ADD KEY `mac_2` (`mac`),
  529. ADD KEY `ip_2` (`ip`);
  530. ALTER TABLE `mac_vendors`
  531. ADD PRIMARY KEY (`id`),
  532. ADD KEY `oui` (`oui`);
  533. ALTER TABLE `ou`
  534. ADD PRIMARY KEY (`id`);
  535. ALTER TABLE `ou` ADD FULLTEXT KEY `ou_name` (`ou_name`);
  536. ALTER TABLE `queue_list`
  537. ADD PRIMARY KEY (`id`),
  538. ADD UNIQUE KEY `id` (`id`);
  539. ALTER TABLE `remote_syslog`
  540. ADD PRIMARY KEY (`id`),
  541. ADD KEY `date` (`ts`,`device_id`,`ip`);
  542. ALTER TABLE `sessions`
  543. ADD PRIMARY KEY (`id`),
  544. ADD KEY `last_accessed` (`last_accessed`);
  545. ALTER TABLE `subnets`
  546. ADD PRIMARY KEY (`id`),
  547. ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
  548. ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
  549. ALTER TABLE `traffic_detail`
  550. ADD PRIMARY KEY (`id`),
  551. ADD KEY `src` (`auth_id`,`ts`,`router_id`,`src_ip`) USING BTREE,
  552. ADD KEY `dst` (`auth_id`,`ts`,`router_id`,`dst_ip`) USING BTREE;
  553. ALTER TABLE `unknown_mac`
  554. ADD PRIMARY KEY (`id`),
  555. ADD KEY `ts` (`ts`,`device_id`,`port_id`,`mac`);
  556. ALTER TABLE `user_auth`
  557. ADD PRIMARY KEY (`id`),
  558. ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
  559. ADD KEY `deleted` (`deleted`),
  560. ADD KEY `ou_id` (`ou_id`);
  561. ALTER TABLE `user_auth_alias`
  562. ADD PRIMARY KEY (`id`),
  563. ADD KEY `auth_id` (`auth_id`);
  564. ALTER TABLE `user_list`
  565. ADD PRIMARY KEY (`id`),
  566. ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
  567. ALTER TABLE `user_sessions`
  568. ADD PRIMARY KEY (`id`),
  569. ADD KEY `session_id` (`session_id`),
  570. ADD KEY `user_id` (`user_id`),
  571. ADD KEY `is_active` (`is_active`);
  572. ALTER TABLE `user_stats`
  573. ADD PRIMARY KEY (`id`),
  574. ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
  575. ALTER TABLE `user_stats_full`
  576. ADD PRIMARY KEY (`id`),
  577. ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
  578. ALTER TABLE `variables`
  579. ADD PRIMARY KEY (`id`),
  580. ADD UNIQUE KEY `name` (`name`),
  581. ADD KEY `clear_time` (`clear_time`,`created`);
  582. ALTER TABLE `vendors`
  583. ADD PRIMARY KEY (`id`);
  584. ALTER TABLE `version`
  585. ADD UNIQUE KEY `id` (`id`);
  586. ALTER TABLE `wan_stats`
  587. ADD PRIMARY KEY (`id`),
  588. ADD UNIQUE KEY `main` (`ts`,`router_id`,`interface_id`),
  589. ADD KEY `times` (`ts`);
  590. ALTER TABLE `worklog`
  591. ADD PRIMARY KEY (`id`),
  592. ADD KEY `idx_customer` (`customer`,`level`,`ts`),
  593. ADD KEY `idx_timestamp` (`level`,`ts`),
  594. ADD KEY `idx_auth_id` (`auth_id`,`level`,`ts`);
  595. ALTER TABLE `worklog` ADD INDEX `idx_ts` (`ts`);
  596. ALTER TABLE `acl`
  597. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  598. ALTER TABLE `ad_comp_cache`
  599. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  600. ALTER TABLE `auth_rules`
  601. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  602. ALTER TABLE `building`
  603. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  604. ALTER TABLE `config`
  605. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  606. ALTER TABLE `config_options`
  607. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  608. ALTER TABLE `connections`
  609. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  610. ALTER TABLE `customers`
  611. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  612. ALTER TABLE `devices`
  613. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  614. ALTER TABLE `device_filter_instances`
  615. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  616. ALTER TABLE `device_l3_interfaces`
  617. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  618. ALTER TABLE `device_models`
  619. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  620. ALTER TABLE `device_ports`
  621. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  622. ALTER TABLE `device_types`
  623. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  624. ALTER TABLE `dhcp_log`
  625. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  626. ALTER TABLE `dhcp_queue`
  627. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  628. ALTER TABLE `dns_cache`
  629. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  630. ALTER TABLE `dns_queue`
  631. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  632. ALTER TABLE `filter_instances`
  633. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  634. ALTER TABLE `filter_list`
  635. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  636. ALTER TABLE `gateway_subnets`
  637. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  638. ALTER TABLE `group_filters`
  639. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  640. ALTER TABLE `group_list`
  641. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  642. ALTER TABLE `mac_history`
  643. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  644. ALTER TABLE `mac_vendors`
  645. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  646. ALTER TABLE `ou`
  647. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  648. ALTER TABLE `queue_list`
  649. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  650. ALTER TABLE `remote_syslog`
  651. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  652. ALTER TABLE `subnets`
  653. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  654. ALTER TABLE `traffic_detail`
  655. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  656. ALTER TABLE `unknown_mac`
  657. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  658. ALTER TABLE `user_auth`
  659. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  660. ALTER TABLE `user_auth_alias`
  661. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  662. ALTER TABLE `user_list`
  663. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  664. ALTER TABLE `user_sessions`
  665. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  666. ALTER TABLE `user_stats`
  667. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  668. ALTER TABLE `user_stats_full`
  669. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  670. ALTER TABLE `variables`
  671. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  672. ALTER TABLE `vendors`
  673. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  674. ALTER TABLE `wan_stats`
  675. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  676. ALTER TABLE `worklog`
  677. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  678. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  679. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  680. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;