create_db.sql 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  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. `dstport` varchar(20) DEFAULT NULL,
  196. `srcport` varchar(20) DEFAULT NULL,
  197. `filter_type` int(10) UNSIGNED NOT NULL DEFAULT 0
  198. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  199. CREATE TABLE `gateway_subnets` (
  200. `id` int(11) NOT NULL,
  201. `device_id` int(11) DEFAULT NULL,
  202. `subnet_id` int(11) DEFAULT NULL
  203. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  204. CREATE TABLE `group_filters` (
  205. `id` int(11) NOT NULL,
  206. `group_id` int(11) NOT NULL DEFAULT 0,
  207. `filter_id` int(11) NOT NULL DEFAULT 0,
  208. `rule_order` int(11) NOT NULL DEFAULT 0,
  209. `action` tinyint(1) NOT NULL DEFAULT 0
  210. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  211. CREATE TABLE `group_list` (
  212. `id` int(11) NOT NULL,
  213. `instance_id` int(11) NOT NULL DEFAULT 1,
  214. `group_name` varchar(50) DEFAULT NULL,
  215. `description` varchar(250) DEFAULT NULL
  216. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  217. CREATE TABLE `mac_history` (
  218. `id` bigint(20) UNSIGNED NOT NULL,
  219. `mac` varchar(17) DEFAULT NULL,
  220. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  221. `device_id` bigint(20) UNSIGNED DEFAULT NULL,
  222. `port_id` bigint(20) UNSIGNED DEFAULT NULL,
  223. `ip` varchar(15) DEFAULT NULL,
  224. `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
  225. `dhcp_hostname` varchar(250) DEFAULT NULL
  226. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  227. CREATE TABLE `mac_vendors` (
  228. `id` int(11) NOT NULL,
  229. `oui` varchar(20) DEFAULT NULL,
  230. `companyname` varchar(255) DEFAULT NULL,
  231. `companyaddress` varchar(255) DEFAULT NULL
  232. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  233. CREATE TABLE `ou` (
  234. `id` int(11) NOT NULL,
  235. `ou_name` varchar(40) DEFAULT NULL,
  236. `description` varchar(250) DEFAULT NULL,
  237. `default_users` tinyint(1) NOT NULL DEFAULT 0,
  238. `default_hotspot` tinyint(1) NOT NULL DEFAULT 0,
  239. `nagios_dir` varchar(255) DEFAULT NULL,
  240. `nagios_host_use` varchar(50) DEFAULT NULL,
  241. `nagios_ping` tinyint(1) NOT NULL DEFAULT 1,
  242. `nagios_default_service` varchar(100) DEFAULT NULL,
  243. `enabled` int(11) NOT NULL DEFAULT 0,
  244. `filter_group_id` int(11) NOT NULL DEFAULT 0,
  245. `queue_id` int(11) NOT NULL DEFAULT 0,
  246. `dynamic` tinyint(1) NOT NULL DEFAULT 0,
  247. `life_duration` decimal(10,2) NOT NULL DEFAULT 24.00,
  248. `parent_id` int(11) DEFAULT NULL
  249. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  250. CREATE TABLE `queue_list` (
  251. `id` int(11) NOT NULL,
  252. `queue_name` varchar(20) NOT NULL,
  253. `download` int(11) NOT NULL DEFAULT 0,
  254. `upload` int(11) NOT NULL DEFAULT 0
  255. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  256. CREATE TABLE `remote_syslog` (
  257. `id` bigint(20) UNSIGNED NOT NULL,
  258. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  259. `device_id` bigint(20) UNSIGNED NOT NULL,
  260. `ip` varchar(15) DEFAULT NULL,
  261. `message` text NOT NULL
  262. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
  263. CREATE TABLE `sessions` (
  264. `id` varchar(128) NOT NULL,
  265. `data` text NOT NULL,
  266. `last_accessed` int(11) NOT NULL
  267. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  268. CREATE TABLE `subnets` (
  269. `id` int(11) NOT NULL,
  270. `subnet` varchar(18) DEFAULT NULL,
  271. `vlan_tag` int(11) NOT NULL DEFAULT 1,
  272. `ip_int_start` bigint(20) NOT NULL,
  273. `ip_int_stop` bigint(20) NOT NULL,
  274. `dhcp_start` bigint(20) NOT NULL DEFAULT 0,
  275. `dhcp_stop` bigint(20) NOT NULL DEFAULT 0,
  276. `dhcp_lease_time` int(11) NOT NULL DEFAULT 480,
  277. `gateway` bigint(20) NOT NULL DEFAULT 0,
  278. `office` tinyint(1) NOT NULL DEFAULT 1,
  279. `hotspot` tinyint(1) NOT NULL DEFAULT 0,
  280. `vpn` tinyint(1) NOT NULL DEFAULT 0,
  281. `free` tinyint(1) NOT NULL DEFAULT 0,
  282. `dhcp` tinyint(1) NOT NULL DEFAULT 1,
  283. `static` tinyint(1) NOT NULL DEFAULT 0,
  284. `dhcp_update_hostname` tinyint(1) NOT NULL DEFAULT 0,
  285. `discovery` tinyint(1) NOT NULL DEFAULT 1,
  286. `notify` tinyint(1) NOT NULL DEFAULT 7,
  287. `description` varchar(250) DEFAULT NULL
  288. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  289. CREATE TABLE `traffic_detail` (
  290. `id` bigint(20) UNSIGNED NOT NULL,
  291. `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
  292. `router_id` int(11) NOT NULL DEFAULT 0,
  293. `ts` DATETIME NULL DEFAULT NULL,
  294. `proto` tinyint(3) UNSIGNED DEFAULT NULL,
  295. `src_ip` bigint(20) NOT NULL DEFAULT 0,
  296. `dst_ip` bigint(20) NOT NULL DEFAULT 0,
  297. `src_port` smallint(5) UNSIGNED NOT NULL,
  298. `dst_port` smallint(5) UNSIGNED NOT NULL,
  299. `bytes` bigint(20) NOT NULL,
  300. `pkt` int(10) UNSIGNED NOT NULL DEFAULT 0
  301. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  302. CREATE TABLE `unknown_mac` (
  303. `id` bigint(20) UNSIGNED NOT NULL,
  304. `mac` varchar(17) DEFAULT NULL,
  305. `port_id` bigint(20) UNSIGNED DEFAULT NULL,
  306. `device_id` int(11) DEFAULT NULL,
  307. `ts` DATETIME NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
  308. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  309. CREATE TABLE `user_auth` (
  310. `id` int(11) NOT NULL,
  311. `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  312. `ou_id` int(11) DEFAULT NULL,
  313. `ip` varchar(18) DEFAULT NULL,
  314. `ip_int` bigint(10) UNSIGNED NOT NULL DEFAULT 0,
  315. `save_traf` tinyint(1) NOT NULL DEFAULT 0,
  316. `enabled` tinyint(1) NOT NULL DEFAULT 0,
  317. `dhcp` tinyint(1) NOT NULL DEFAULT 1,
  318. `filter_group_id` tinyint(1) NOT NULL DEFAULT 0,
  319. `dynamic` tinyint(1) NOT NULL DEFAULT 0,
  320. `end_life` datetime DEFAULT NULL,
  321. `deleted` tinyint(4) NOT NULL DEFAULT 0,
  322. `description` varchar(250) DEFAULT NULL,
  323. `dns_name` varchar(253) DEFAULT NULL,
  324. `dns_ptr_only` tinyint(1) NOT NULL DEFAULT 0,
  325. `wikiname` varchar(250) DEFAULT NULL,
  326. `dhcp_acl` text DEFAULT NULL,
  327. `queue_id` int(11) NOT NULL DEFAULT 0,
  328. `mac` varchar(17) DEFAULT NULL,
  329. `dhcp_action` varchar(10) NOT NULL DEFAULT '',
  330. `dhcp_option_set` varchar(50) DEFAULT NULL,
  331. `dhcp_time` datetime DEFAULT NULL,
  332. `dhcp_hostname` varchar(60) DEFAULT NULL,
  333. `last_found` datetime NOT NULL DEFAULT current_timestamp(),
  334. `arp_found` datetime DEFAULT NULL,
  335. `mac_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. `ts` DATETIME 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. `ts` DATETIME 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. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  362. `login` varchar(255) DEFAULT NULL,
  363. `description` 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. `ts` 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. `pkt_in` int(11) NOT NULL DEFAULT 0,
  393. `pkt_out` int(11) NOT NULL DEFAULT 0,
  394. `step` int(11) NOT NULL DEFAULT 3600
  395. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  396. CREATE TABLE `user_stats_full` (
  397. `id` bigint(20) UNSIGNED NOT NULL,
  398. `router_id` bigint(20) UNSIGNED DEFAULT 0,
  399. `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  400. `ts` datetime NOT NULL DEFAULT current_timestamp(),
  401. `byte_in` bigint(20) NOT NULL DEFAULT 0,
  402. `byte_out` bigint(20) NOT NULL DEFAULT 0,
  403. `pkt_in` int(11) NOT NULL DEFAULT 0,
  404. `pkt_out` int(11) NOT NULL DEFAULT 0,
  405. `step` int(11) NOT NULL DEFAULT 600
  406. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  407. CREATE TABLE `variables` (
  408. `id` int(11) NOT NULL,
  409. `name` varchar(30) NOT NULL,
  410. `value` varchar(255) DEFAULT NULL,
  411. `clear_time` DATETIME NOT NULL DEFAULT current_timestamp(),
  412. `created` DATETIME NOT NULL DEFAULT current_timestamp()
  413. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  414. CREATE TABLE `vendors` (
  415. `id` int(11) NOT NULL,
  416. `name` varchar(40) NOT NULL
  417. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  418. CREATE TABLE `version` (
  419. `id` int(11) NOT NULL DEFAULT 1,
  420. `version` varchar(10) NOT NULL DEFAULT '2.4.14'
  421. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  422. CREATE TABLE `wan_stats` (
  423. `id` int(11) NOT NULL,
  424. `ts` datetime NOT NULL DEFAULT current_timestamp(),
  425. `router_id` int(11) DEFAULT NULL,
  426. `interface_id` int(11) DEFAULT NULL,
  427. `bytes_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  428. `bytes_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  429. `forward_in` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  430. `forward_out` bigint(20) UNSIGNED NOT NULL DEFAULT 0
  431. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  432. CREATE TABLE `worklog` (
  433. `id` bigint(20) UNSIGNED NOT NULL,
  434. `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
  435. `auth_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  436. `customer` varchar(50) NOT NULL DEFAULT 'system',
  437. `ip` varchar(18) NOT NULL DEFAULT '127.0.0.1',
  438. `message` text NOT NULL,
  439. `level` int(11) NOT NULL DEFAULT 1
  440. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
  441. ALTER TABLE `acl`
  442. ADD PRIMARY KEY (`id`);
  443. ALTER TABLE `ad_comp_cache`
  444. ADD PRIMARY KEY (`id`),
  445. ADD UNIQUE KEY `comp_name` (`name`);
  446. ALTER TABLE `auth_rules`
  447. ADD PRIMARY KEY (`id`),
  448. ADD UNIQUE KEY `rule` (`rule`),
  449. ADD KEY `user_id` (`user_id`);
  450. ALTER TABLE `building`
  451. ADD PRIMARY KEY (`id`);
  452. ALTER TABLE `config`
  453. ADD PRIMARY KEY (`id`),
  454. ADD KEY `option` (`option_id`);
  455. ALTER TABLE `config_options`
  456. ADD PRIMARY KEY (`id`);
  457. ALTER TABLE `connections`
  458. ADD PRIMARY KEY (`id`),
  459. ADD KEY `auth_id` (`auth_id`),
  460. ADD KEY `device_id` (`device_id`,`port_id`);
  461. ALTER TABLE `customers`
  462. ADD PRIMARY KEY (`id`);
  463. ALTER TABLE `devices`
  464. ADD PRIMARY KEY (`id`),
  465. ADD KEY `ip` (`ip`),
  466. ADD KEY `device_type` (`device_type`);
  467. ALTER TABLE `device_filter_instances`
  468. ADD PRIMARY KEY (`id`);
  469. ALTER TABLE `device_l3_interfaces`
  470. ADD PRIMARY KEY (`id`);
  471. ALTER TABLE `device_models`
  472. ADD PRIMARY KEY (`id`);
  473. ALTER TABLE `device_ports`
  474. ADD PRIMARY KEY (`id`),
  475. ADD KEY `device_id` (`device_id`),
  476. ADD KEY `port` (`port`),
  477. ADD KEY `target_port_id` (`target_port_id`);
  478. ALTER TABLE `device_types`
  479. ADD PRIMARY KEY (`id`);
  480. ALTER TABLE `dhcp_log`
  481. ADD PRIMARY KEY (`id`),
  482. ADD KEY `ts` (`ts`,`action`);
  483. ALTER TABLE `dhcp_queue`
  484. ADD PRIMARY KEY (`id`),
  485. ADD KEY `ts` (`ts`,`action`);
  486. ALTER TABLE `dns_cache`
  487. ADD PRIMARY KEY (`id`),
  488. ADD KEY `dns` (`dns`,`ip`),
  489. ADD KEY `ts` (`ts`);
  490. ALTER TABLE `dns_queue`
  491. ADD PRIMARY KEY (`id`);
  492. ALTER TABLE `filter_instances`
  493. ADD PRIMARY KEY (`id`),
  494. ADD UNIQUE KEY `name` (`name`);
  495. ALTER TABLE `filter_list`
  496. ADD PRIMARY KEY (`id`),
  497. ADD KEY `Name` (`name`);
  498. ALTER TABLE `gateway_subnets`
  499. ADD PRIMARY KEY (`id`);
  500. ALTER TABLE `group_filters`
  501. ADD PRIMARY KEY (`id`),
  502. ADD KEY `GroupId` (`group_id`,`filter_id`);
  503. ALTER TABLE `group_list`
  504. ADD PRIMARY KEY (`id`);
  505. ALTER TABLE `mac_history`
  506. ADD PRIMARY KEY (`id`),
  507. ADD KEY `mac` (`mac`,`ts`),
  508. ADD KEY `ip` (`ip`,`ts`),
  509. ADD KEY `ts` (`ts`) USING BTREE,
  510. ADD KEY `mac_2` (`mac`),
  511. ADD KEY `ip_2` (`ip`);
  512. ALTER TABLE `mac_vendors`
  513. ADD PRIMARY KEY (`id`),
  514. ADD KEY `oui` (`oui`);
  515. ALTER TABLE `ou`
  516. ADD PRIMARY KEY (`id`);
  517. ALTER TABLE `ou` ADD FULLTEXT KEY `ou_name` (`ou_name`);
  518. ALTER TABLE `queue_list`
  519. ADD PRIMARY KEY (`id`),
  520. ADD UNIQUE KEY `id` (`id`);
  521. ALTER TABLE `remote_syslog`
  522. ADD PRIMARY KEY (`id`),
  523. ADD KEY `date` (`ts`,`device_id`,`ip`);
  524. ALTER TABLE `sessions`
  525. ADD PRIMARY KEY (`id`),
  526. ADD KEY `last_accessed` (`last_accessed`);
  527. ALTER TABLE `subnets`
  528. ADD PRIMARY KEY (`id`),
  529. ADD KEY `ip_int_start` (`ip_int_start`,`ip_int_stop`),
  530. ADD KEY `dhcp` (`dhcp`,`office`,`hotspot`,`static`);
  531. ALTER TABLE `traffic_detail`
  532. ADD PRIMARY KEY (`id`),
  533. ADD KEY `src` (`auth_id`,`ts`,`router_id`,`src_ip`) USING BTREE,
  534. ADD KEY `dst` (`auth_id`,`ts`,`router_id`,`dst_ip`) USING BTREE;
  535. ALTER TABLE `unknown_mac`
  536. ADD PRIMARY KEY (`id`),
  537. ADD KEY `ts` (`ts`,`device_id`,`port_id`,`mac`);
  538. ALTER TABLE `user_auth`
  539. ADD PRIMARY KEY (`id`),
  540. ADD KEY `auth_index` (`id`,`user_id`,`ip_int`,`mac`,`ip`,`deleted`) USING BTREE,
  541. ADD KEY `deleted` (`deleted`),
  542. ADD KEY `ou_id` (`ou_id`);
  543. ALTER TABLE `user_auth_alias`
  544. ADD PRIMARY KEY (`id`),
  545. ADD KEY `auth_id` (`auth_id`);
  546. ALTER TABLE `user_list`
  547. ADD PRIMARY KEY (`id`),
  548. ADD KEY `users` (`id`,`ou_id`,`enabled`,`blocked`,`deleted`);
  549. ALTER TABLE `user_sessions`
  550. ADD PRIMARY KEY (`id`),
  551. ADD KEY `session_id` (`session_id`),
  552. ADD KEY `user_id` (`user_id`),
  553. ADD KEY `is_active` (`is_active`);
  554. ALTER TABLE `user_stats`
  555. ADD PRIMARY KEY (`id`),
  556. ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
  557. ALTER TABLE `user_stats_full`
  558. ADD PRIMARY KEY (`id`),
  559. ADD KEY `ts` (`ts`,`auth_id`,`router_id`);
  560. ALTER TABLE `variables`
  561. ADD PRIMARY KEY (`id`),
  562. ADD UNIQUE KEY `name` (`name`),
  563. ADD KEY `clear_time` (`clear_time`,`created`);
  564. ALTER TABLE `vendors`
  565. ADD PRIMARY KEY (`id`);
  566. ALTER TABLE `version`
  567. ADD UNIQUE KEY `id` (`id`);
  568. ALTER TABLE `wan_stats`
  569. ADD PRIMARY KEY (`id`),
  570. ADD UNIQUE KEY `main` (`ts`,`router_id`,`interface_id`),
  571. ADD KEY `times` (`ts`);
  572. ALTER TABLE `worklog`
  573. ADD PRIMARY KEY (`id`),
  574. ADD KEY `idx_customer` (`customer`,`level`,`ts`),
  575. ADD KEY `idx_timestamp` (`level`,`ts`),
  576. ADD KEY `idx_auth_id` (`auth_id`,`level`,`ts`);
  577. ALTER TABLE `worklog` ADD INDEX `idx_ts` (`ts`);
  578. ALTER TABLE `acl`
  579. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  580. ALTER TABLE `ad_comp_cache`
  581. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  582. ALTER TABLE `auth_rules`
  583. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  584. ALTER TABLE `building`
  585. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  586. ALTER TABLE `config`
  587. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  588. ALTER TABLE `config_options`
  589. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  590. ALTER TABLE `connections`
  591. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  592. ALTER TABLE `customers`
  593. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  594. ALTER TABLE `devices`
  595. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  596. ALTER TABLE `device_filter_instances`
  597. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  598. ALTER TABLE `device_l3_interfaces`
  599. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  600. ALTER TABLE `device_models`
  601. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  602. ALTER TABLE `device_ports`
  603. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  604. ALTER TABLE `device_types`
  605. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  606. ALTER TABLE `dhcp_log`
  607. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  608. ALTER TABLE `dhcp_queue`
  609. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  610. ALTER TABLE `dns_cache`
  611. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  612. ALTER TABLE `dns_queue`
  613. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  614. ALTER TABLE `filter_instances`
  615. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  616. ALTER TABLE `filter_list`
  617. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  618. ALTER TABLE `gateway_subnets`
  619. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  620. ALTER TABLE `group_filters`
  621. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  622. ALTER TABLE `group_list`
  623. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  624. ALTER TABLE `mac_history`
  625. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  626. ALTER TABLE `mac_vendors`
  627. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  628. ALTER TABLE `ou`
  629. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  630. ALTER TABLE `queue_list`
  631. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  632. ALTER TABLE `remote_syslog`
  633. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  634. ALTER TABLE `subnets`
  635. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  636. ALTER TABLE `traffic_detail`
  637. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  638. ALTER TABLE `unknown_mac`
  639. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  640. ALTER TABLE `user_auth`
  641. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  642. ALTER TABLE `user_auth_alias`
  643. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  644. ALTER TABLE `user_list`
  645. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  646. ALTER TABLE `user_sessions`
  647. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  648. ALTER TABLE `user_stats`
  649. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  650. ALTER TABLE `user_stats_full`
  651. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  652. ALTER TABLE `variables`
  653. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  654. ALTER TABLE `vendors`
  655. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  656. ALTER TABLE `wan_stats`
  657. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  658. ALTER TABLE `worklog`
  659. MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
  660. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  661. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  662. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;