2 -- Table structure for table `roles`
5 -- This must be done first
6 DROP TABLE IF EXISTS `roles_users`;
8 DROP TABLE IF EXISTS `roles`;
9 CREATE TABLE IF NOT EXISTS `roles` (
10 `id` int(11) unsigned NOT NULL auto_increment,
11 `name` varchar(100) NOT NULL,
12 `description` varchar(255) NOT NULL,
14 UNIQUE KEY `uniq_name` (`name`)
18 -- Data for table `roles`
21 INSERT INTO `roles` (`id`, `name`, `description`) VALUES
22 (1, 'login', 'Login privileges, granted after account confirmation'),
23 (2, 'admin', 'Administrative user, has access to everything.');
25 -- --------------------------------------------------------
28 -- Table structure for table `roles_users`
31 CREATE TABLE IF NOT EXISTS `roles_users` (
32 `user_id` int(10) unsigned NOT NULL,
33 `role_id` int(10) unsigned NOT NULL,
34 PRIMARY KEY (`user_id`,`role_id`),
35 KEY `fk_role_id` (`role_id`)
38 -- --------------------------------------------------------
41 -- Table structure for table `users`
44 -- This must be done first
45 DROP TABLE IF EXISTS `user_tokens`;
47 DROP TABLE IF EXISTS `users`;
48 CREATE TABLE IF NOT EXISTS `users` (
49 `id` int(11) unsigned NOT NULL auto_increment,
50 `realname` varchar(100) NOT NULL,
51 `email` varchar(127) NOT NULL,
52 `username` varchar(100) NOT NULL default '',
53 `password_algo` varchar(20) NOT NULL default 'b64_sha1',
54 `password` varchar(50) NOT NULL,
55 `logins` int(10) unsigned NOT NULL default '0',
56 `last_login` int(10) unsigned default NULL,
58 UNIQUE KEY `uniq_username` (`username`)
59 ) COLLATE latin1_general_cs;
63 -- Table structure for table `user_tokens`;
66 CREATE TABLE IF NOT EXISTS `user_tokens` (
67 id int(11) unsigned NOT NULL auto_increment,
68 user_id int(11) unsigned NOT NULL,
69 user_agent varchar(40) NOT NULL,
70 token varchar(32) NOT NULL,
71 created int(10) unsigned NOT NULL,
72 expires int(10) unsigned NOT NULL,
74 UNIQUE KEY uniq_token (token),
75 KEY fk_user_id (user_id)
79 -- Table structure for table `ninja_settings`
82 DROP TABLE IF EXISTS `ninja_settings`;
83 CREATE TABLE IF NOT EXISTS `ninja_settings` (
84 `id` int(11) NOT NULL auto_increment,
85 `username` varchar(200) NOT NULL,
86 `page` varchar(200) NOT NULL,
87 `type` varchar(200) NOT NULL,
88 `setting` text NOT NULL,
89 `widget_id` int(11) default NULL,
91 KEY `username` (`username`),
93 KEY `widget_id` (`widget_id`)
96 INSERT INTO `ninja_settings` (`page`, `type`, `setting`)
97 VALUES('tac/index', 'widget_order', 'widget-placeholder=widget-netw_outages,widget-tac_scheduled,widget-monitoring_performance|widget-placeholder1=widget-tac_disabled,widget-tac_acknowledged|widget-placeholder2=widget-netw_health,widget-geomap|widget-placeholder3=widget-tac_hosts,widget-tac_services,widget-tac_monfeat,widget-tac_problems');
99 -- --------------------------------------------------------
102 -- Table structure for table `ninja_widgets`
105 DROP TABLE IF EXISTS `ninja_widgets`;
106 CREATE TABLE IF NOT EXISTS `ninja_widgets` (
107 `id` int(11) NOT NULL auto_increment,
108 `username` varchar(200) NOT NULL,
109 `page` varchar(200) NOT NULL,
110 `name` varchar(255) NOT NULL,
111 `friendly_name` varchar(255) NOT NULL,
112 `setting` text NOT NULL,
114 KEY `username` (`username`)
118 -- Data for table `ninja_widgets`
121 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
122 (1, '', 'tac/index', 'tac_problems', 'Unhandled problems', '');
123 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
124 (2, '', 'tac/index', 'netw_health', 'Network health', '');
125 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
126 (3, '', 'tac/index', 'tac_scheduled', 'Scheduled downtime', '');
127 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
128 (4, '', 'tac/index', 'tac_acknowledged', 'Acknowledged problems', '');
129 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
130 (5, '', 'tac/index', 'tac_disabled', 'Disabled checks', '');
131 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
132 (6, '', 'tac/index', 'netw_outages', 'Network outages', '');
133 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
134 (7, '', 'tac/index', 'tac_hosts', 'Hosts', '');
135 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
136 (8, '', 'tac/index', 'tac_services', 'Services', '');
137 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
138 (9, '', 'tac/index', 'tac_monfeat', 'Monitoring features', '');
139 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
140 (10, '', 'status', 'status_totals', 'Status Totals', '');
141 INSERT INTO `ninja_widgets` (`id`, `username`, `page`, `name`, `friendly_name`, `setting`) VALUES \
142 (11, '', 'tac/index', 'monitoring_performance', 'Monitoring Performance', '');
145 -- Table structure for table `ninja_db_version`
148 CREATE TABLE IF NOT EXISTS `ninja_db_version` (
149 `id` int(11) NOT NULL auto_increment,
150 `version` int(11) NOT NULL default '0',
155 -- Data for table `ninja_db_version`
158 INSERT INTO `ninja_db_version` (`id`, `version`) VALUES(1, 1);
161 -- Table structure for table `ninja_user_authorization`
164 DROP TABLE IF EXISTS `ninja_user_authorization`;
165 CREATE TABLE IF NOT EXISTS `ninja_user_authorization` (
166 `id` int(11) NOT NULL auto_increment,
167 `user_id` int(11) NOT NULL,
168 `system_information` int(11) NOT NULL default '0',
169 `configuration_information` int(11) NOT NULL default '0',
170 `system_commands` int(11) NOT NULL default '0',
171 `all_services` int(11) NOT NULL default '0',
172 `all_hosts` int(11) NOT NULL default '0',
173 `all_service_commands` int(11) NOT NULL default '0',
174 `all_host_commands` int(11) NOT NULL default '0',
176 KEY `user_id` (`user_id`)