1 CREATE SEQUENCE ninja_widgets_id_SEQ
2 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
4 CREATE SEQUENCE recurring_downtime_id_SEQ
5 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
7 CREATE SEQUENCE scheduled_report_types_id_SEQ
8 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
10 CREATE SEQUENCE avail_config_objects_id_SEQ
11 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
13 CREATE SEQUENCE roles_id_SEQ
14 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
16 CREATE SEQUENCE ninja_user_authorization_id_SE
17 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
19 CREATE SEQUENCE scheduled_report_periods_id_SE
20 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
22 CREATE SEQUENCE users_id_SEQ
23 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
25 CREATE SEQUENCE sla_periods_id_SEQ
26 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
28 CREATE SEQUENCE sla_config_id_SEQ
29 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
31 CREATE SEQUENCE ninja_settings_id_SEQ
32 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
34 CREATE SEQUENCE scheduled_reports_id_SEQ
35 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
37 CREATE SEQUENCE sla_config_objects_id_SEQ
38 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
40 CREATE SEQUENCE user_tokens_id_SEQ
41 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
43 CREATE SEQUENCE avail_config_id_SEQ
44 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
46 CREATE SEQUENCE ninja_db_version_id_SEQ
47 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
49 CREATE SEQUENCE summary_config_id_SEQ
50 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
52 CREATE SEQUENCE saved_searches_id_SEQ
53 MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 NOCYCLE ;
55 CREATE TABLE ninja_saved_searches (
56 id NUMBER(10,0) NOT NULL,
57 username VARCHAR2(255 CHAR) DEFAULT NULL,
58 search_name VARCHAR2(255 CHAR) NOT NULL,
59 search_query VARCHAR2(255 CHAR) NOT NULL,
60 search_description VARCHAR2(255 CHAR) NOT NULL
62 ALTER TABLE ninja_saved_searches ADD CONSTRAINT ninja_saved_searches_pk PRIMARY KEY(id) ENABLE;
63 CREATE INDEX n_s_s_username ON ninja_saved_searches(username);
65 CREATE TABLE avail_config (
66 id NUMBER(10,0) NOT NULL,
67 username VARCHAR2(255 CHAR) DEFAULT NULL,
68 report_name VARCHAR2(255 CHAR) NOT NULL,
69 info CLOB DEFAULT NULL,
70 created DATE DEFAULT SYSDATE NOT NULL,
71 rpttimeperiod VARCHAR2(75 CHAR) DEFAULT NULL,
72 report_period VARCHAR2(50 CHAR) DEFAULT NULL,
73 start_time NUMBER(10,0) DEFAULT '0' NOT NULL,
74 end_time NUMBER(10,0) DEFAULT '0' NOT NULL,
75 report_type VARCHAR2(30 CHAR) NOT NULL,
76 initialassumedhoststate NUMBER(10,0) DEFAULT '0',
77 initialassumedservicestate NUMBER(10,0) DEFAULT '0',
78 assumeinitialstates NUMBER(10,0) DEFAULT '0' NOT NULL,
79 scheduleddowntimeasuptime NUMBER(10,0) DEFAULT '0',
80 assumestatesduringnotrunning NUMBER(10,0) DEFAULT '0',
81 includesoftstates NUMBER(10,0) DEFAULT '0',
82 updated DATE DEFAULT to_date('01-JAN-70 00:00:00', 'dd-MON-yy hh24:mi:ss') NOT NULL,
83 use_average NUMBER(3,0) DEFAULT '0',
84 use_alias NUMBER(3,0) DEFAULT '0',
85 cluster_mode NUMBER(10,0) DEFAULT '0',
86 host_filter_status VARCHAR(100 CHAR) DEFAULT NULL,
87 service_filter_status VARCHAR(100 CHAR) DEFAULT NULL,
88 use_summary NUMBER(3,0) DEFAULT '0',
89 use_pnp NUMBER(3,0) DEFAULT '0',
90 summary_report_type NUMBER(3,0) DEFAULT '0',
91 summary_items NUMBER(3,0) DEFAULT '0',
92 alert_types NUMBER(3,0) DEFAULT '0',
93 state_types NUMBER(3,0) DEFAULT '0',
94 host_states NUMBER(3,0) DEFAULT '0',
95 service_states NUMBER(3,0) DEFAULT '0'
97 ALTER TABLE avail_config ADD CONSTRAINT avail_config_pk PRIMARY KEY(id) ENABLE;
98 CREATE INDEX user_1 ON avail_config(username);
100 CREATE TABLE avail_config_objects (
101 id NUMBER(10,0) NOT NULL,
102 avail_id NUMBER(10,0) DEFAULT '0' NOT NULL,
103 name VARCHAR2(255 CHAR) NOT NULL
105 ALTER TABLE avail_config_objects ADD CONSTRAINT avail_config_objects_pk PRIMARY KEY(id) ENABLE;
106 CREATE INDEX avail_id ON avail_config_objects(avail_id);
108 CREATE TABLE avail_db_version (
109 version NUMBER(10,0) DEFAULT '0' NOT NULL
111 INSERT INTO avail_db_version VALUES(7);
114 CREATE TABLE summary_config (
115 id NUMBER(11,0) NOT NULL,
116 username varchar2(200 CHAR) NOT NULL,
117 report_name varchar2(200 CHAR) NOT NULL,
118 setting CLOB NOT NULL
120 ALTER TABLE summary_config ADD CONSTRAINT summary_config_pk PRIMARY KEY(id) ENABLE;
121 CREATE INDEX username_sum_conf ON summary_config(username);
123 PROMPT Creating Table ninja_db_version ...
124 CREATE TABLE ninja_db_version (
125 id NUMBER(10,0) NOT NULL,
126 version NUMBER(10,0) DEFAULT '0' NOT NULL
128 ALTER TABLE ninja_db_version ADD CONSTRAINT ninja_db_version_pk PRIMARY KEY(id) ENABLE;
130 INSERT INTO ninja_db_version (id, version) VALUES(1, 1);
133 CREATE TABLE ninja_settings (
134 id NUMBER(10,0) NOT NULL,
135 username VARCHAR2(200 CHAR) DEFAULT NULL,
136 page VARCHAR2(200 CHAR) NOT NULL,
137 type VARCHAR2(200 CHAR) NOT NULL,
138 setting CLOB DEFAULT NULL,
139 widget_id NUMBER(10,0)
141 ALTER TABLE ninja_settings ADD CONSTRAINT ninja_settings_pk PRIMARY KEY(id) ENABLE;
142 CREATE INDEX user_3 ON ninja_settings(username);
143 CREATE INDEX page ON ninja_settings(page);
144 CREATE INDEX widget_id ON ninja_settings(widget_id);
146 INSERT INTO ninja_settings (id,username,page, type, setting)
147 VALUES(1, '', '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');
150 CREATE TABLE ninja_user_authorization (
151 id NUMBER(10,0) NOT NULL,
152 user_id NUMBER(10,0) NOT NULL,
153 system_information NUMBER(10,0) DEFAULT '0' NOT NULL,
154 configuration_information NUMBER(10,0) DEFAULT '0' NOT NULL,
155 system_commands NUMBER(10,0) DEFAULT '0' NOT NULL,
156 all_services NUMBER(10,0) DEFAULT '0' NOT NULL,
157 all_hosts NUMBER(10,0) DEFAULT '0' NOT NULL,
158 all_service_commands NUMBER(10,0) DEFAULT '0' NOT NULL,
159 all_host_commands NUMBER(10,0) DEFAULT '0' NOT NULL
161 ALTER TABLE ninja_user_authorization ADD CONSTRAINT ninja_user_authorization_pk PRIMARY KEY(id) ENABLE;
162 CREATE INDEX user_id ON ninja_user_authorization(user_id);
164 CREATE TABLE ninja_widgets (
165 id NUMBER(10,0) NOT NULL,
166 username VARCHAR2(200 CHAR) DEFAULT NULL,
167 page VARCHAR2(200 CHAR) DEFAULT 'tac/index' NOT NULL,
168 name VARCHAR2(255 CHAR) NOT NULL,
169 friendly_name VARCHAR2(255 CHAR) NOT NULL,
170 setting CLOB DEFAULT NULL
172 ALTER TABLE ninja_widgets ADD CONSTRAINT ninja_widgets_pk PRIMARY KEY(id) ENABLE;
173 CREATE INDEX username ON ninja_widgets(username);
175 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (1, '', 'tac/index', 'tac_problems', 'Unhandled problems', '');
176 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (2, '', 'tac/index', 'netw_health', 'Network health', '');
177 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (3, '', 'tac/index', 'tac_scheduled', 'Scheduled downtime', '');
178 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (4, '', 'tac/index', 'tac_acknowledged', 'Acknowledged problems', '');
179 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (5, '', 'tac/index', 'tac_disabled', 'Disabled checks', '');
180 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (6, '', 'tac/index', 'netw_outages', 'Network outages', '');
181 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (7, '', 'tac/index', 'tac_hosts', 'Hosts', '');
182 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (8, '', 'tac/index', 'tac_services', 'Services', '');
183 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (9, '', 'tac/index', 'tac_monfeat', 'Monitoring features', '');
184 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (10, '', 'status', 'status_totals', 'Status Totals', '');
185 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (11, '', 'tac/index', 'monitoring_performance', 'Monitoring Performance', '');
186 INSERT INTO ninja_widgets (id, username, page, name, friendly_name, setting) VALUES (12, '', 'tac/index', 'geomap', 'Geomap', '');
189 CREATE TABLE recurring_downtime (
190 id NUMBER(10,0) NOT NULL,
191 author VARCHAR2(255 CHAR) NOT NULL,
192 downtime_type VARCHAR2(255 CHAR) NOT NULL,
194 last_update NUMBER(10,0) DEFAULT '0' NOT NULL
196 ALTER TABLE recurring_downtime ADD CONSTRAINT recurring_downtime_pk PRIMARY KEY(id) ENABLE;
197 CREATE INDEX author ON recurring_downtime(author);
198 CREATE INDEX downtime_type ON recurring_downtime(downtime_type);
201 id NUMBER(10,0) NOT NULL,
202 name VARCHAR2(100 CHAR) NOT NULL,
203 description VARCHAR2(255 CHAR) NOT NULL
205 ALTER TABLE roles ADD CONSTRAINT roles_pk PRIMARY KEY(id) ENABLE;
206 CREATE UNIQUE INDEX uniq_name ON roles(name);
208 INSERT INTO roles (id, name, description) VALUES (1, 'login', 'Login privileges, granted after account confirmation');
209 INSERT INTO roles (id, name, description) VALUES (2, 'admin', 'Administrative user, has access to everything.');
212 CREATE TABLE roles_users (
213 user_id NUMBER(10,0) NOT NULL,
214 role_id NUMBER(10,0) NOT NULL
216 ALTER TABLE roles_users ADD CONSTRAINT roles_users_pk PRIMARY KEY(user_id, role_id) ENABLE;
217 CREATE INDEX fk_role_id ON roles_users(role_id);
219 CREATE TABLE scheduled_report_periods (
220 id NUMBER(10,0) NOT NULL,
221 periodname VARCHAR2(100 CHAR) NOT NULL
223 ALTER TABLE scheduled_report_periods ADD CONSTRAINT scheduled_report_periods_pk PRIMARY KEY(id) ENABLE;
225 INSERT INTO scheduled_report_periods (id, periodname) VALUES (1, 'Weekly');
226 INSERT INTO scheduled_report_periods (id, periodname) VALUES (2, 'Monthly');
227 INSERT INTO scheduled_report_periods (id, periodname) VALUES (3, 'Daily');
230 CREATE TABLE scheduled_report_types (
231 id NUMBER(10,0) NOT NULL,
232 name VARCHAR2(255 CHAR) NOT NULL,
233 script_reports_path VARCHAR2(255 CHAR) NOT NULL,
234 script_reports_run VARCHAR2(255 CHAR) NOT NULL,
235 identifier VARCHAR2(50 CHAR) NOT NULL
237 ALTER TABLE scheduled_report_types ADD CONSTRAINT scheduled_report_types_pk PRIMARY KEY(id) ENABLE;
238 CREATE INDEX identifier ON scheduled_report_types(identifier);
240 INSERT INTO scheduled_report_types (id, name, script_reports_path, script_reports_run, identifier) VALUES (1, ' ', ' ', ' ', 'avail');
241 INSERT INTO scheduled_report_types (id, name, script_reports_path, script_reports_run, identifier) VALUES (2, ' ', ' ', ' ', 'sla');
242 INSERT INTO scheduled_report_types (id, name, script_reports_path, script_reports_run, identifier) VALUES (3, ' ', ' ', ' ', 'summary');
245 CREATE TABLE scheduled_reports (
246 id NUMBER(10,0) NOT NULL,
247 username VARCHAR2(255 CHAR) DEFAULT NULL,
248 report_type_id NUMBER(10,0) DEFAULT '0' NOT NULL,
249 report_id NUMBER(10,0) DEFAULT '0' NOT NULL,
250 recipients CLOB NOT NULL,
251 description CLOB NOT NULL,
252 period_id NUMBER(10,0) DEFAULT '0' NOT NULL,
253 filename VARCHAR2(255 CHAR) NOT NULL
255 ALTER TABLE scheduled_reports ADD CONSTRAINT scheduled_reports_pk PRIMARY KEY(id) ENABLE;
256 CREATE INDEX report_type_id ON scheduled_reports(report_type_id);
257 CREATE INDEX user_2 ON scheduled_reports(username);
259 CREATE TABLE scheduled_reports_db_version (
260 version VARCHAR2(10 CHAR) NOT NULL
262 INSERT INTO scheduled_reports_db_version VALUES('1.0.0');
265 CREATE TABLE sla_config (
266 id NUMBER(10,0) NOT NULL,
267 username VARCHAR2(255 CHAR) DEFAULT NULL,
268 sla_name VARCHAR2(255 CHAR) NOT NULL,
269 info CLOB DEFAULT NULL,
270 created DATE DEFAULT SYSDATE NOT NULL,
271 rpttimeperiod VARCHAR2(75 CHAR) DEFAULT NULL,
272 report_period VARCHAR2(50 CHAR) DEFAULT NULL,
273 start_time NUMBER(10,0) DEFAULT '0' NOT NULL,
274 end_time NUMBER(10,0) DEFAULT '0' NOT NULL,
275 report_type VARCHAR2(30 CHAR) NOT NULL,
276 initialassumedhoststate NUMBER(10,0) DEFAULT '0' NOT NULL,
277 initialassumedservicestate NUMBER(10,0) DEFAULT '0' NOT NULL,
278 assumeinitialstates NUMBER(10,0) DEFAULT '0' NOT NULL,
279 scheduleddowntimeasuptime NUMBER(10,0) DEFAULT '0',
280 assumestatesduringnotrunning NUMBER(10,0) DEFAULT '0',
281 includesoftstates NUMBER(10,0) DEFAULT '0',
282 updated DATE DEFAULT to_date('01-JAN-70 00:00:00', 'dd-MON-yy hh24:mi:ss') NOT NULL,
283 use_average NUMBER(3,0) DEFAULT '0',
284 use_alias NUMBER(3,0) DEFAULT '0',
285 cluster_mode NUMBER(10,0) DEFAULT '0',
286 use_summary NUMBER(3,0) DEFAULT '0',
287 use_pnp NUMBER(3,0) DEFAULT '0',
288 summary_report_type NUMBER(3,0) DEFAULT '0',
289 summary_items NUMBER(3,0) DEFAULT '0',
290 alert_types NUMBER(3,0) DEFAULT '0',
291 state_types NUMBER(3,0) DEFAULT '0',
292 host_states NUMBER(3,0) DEFAULT '0',
293 service_states NUMBER(3,0) DEFAULT '0'
295 ALTER TABLE sla_config ADD CONSTRAINT sla_config_pk PRIMARY KEY(id) ENABLE;
297 CREATE TABLE sla_config_objects (
298 id NUMBER(10,0) NOT NULL,
299 sla_id NUMBER(10,0) DEFAULT '0' NOT NULL,
300 name VARCHAR2(255 CHAR) NOT NULL
302 ALTER TABLE sla_config_objects ADD CONSTRAINT sla_config_objects_pk PRIMARY KEY(id)ENABLE;
303 CREATE INDEX sla_id ON sla_config_objects(sla_id);
305 CREATE TABLE sla_db_version (
306 version NUMBER(10,0) DEFAULT '0' NOT NULL
308 INSERT INTO sla_db_version VALUES(7);
311 CREATE TABLE sla_periods (
312 id NUMBER(10,0) NOT NULL,
313 sla_id NUMBER(10,0) DEFAULT '0' NOT NULL,
314 name VARCHAR2(20 CHAR) NOT NULL,
315 value FLOAT DEFAULT '0' NOT NULL
317 ALTER TABLE sla_periods ADD CONSTRAINT sla_periods_pk PRIMARY KEY(id) ENABLE;
318 CREATE INDEX sla_id_1 ON sla_periods(sla_id);
320 CREATE TABLE user_tokens (
321 id NUMBER(10,0) NOT NULL,
322 user_id NUMBER(10,0) NOT NULL,
323 user_agent VARCHAR2(40 CHAR) NOT NULL,
324 token VARCHAR2(32 CHAR) NOT NULL,
325 created NUMBER(10,0) NOT NULL,
326 expires NUMBER(10,0) NOT NULL
330 ALTER TABLE user_tokens ADD CONSTRAINT user_tokens_pk PRIMARY KEY(id) ENABLE;
331 CREATE UNIQUE INDEX uniq_token ON user_tokens(token);
332 CREATE INDEX fk_user_id ON user_tokens(user_id);
335 id NUMBER(10,0) NOT NULL,
336 realname VARCHAR2(100 CHAR) DEFAULT NULL, -- originally: NOT NULL
337 email VARCHAR2(127 CHAR) DEFAULT NULL,
338 username VARCHAR2(100 CHAR) NOT NULL,
339 password_algo VARCHAR2(20 CHAR) DEFAULT 'b64_sha1' NOT NULL,
340 password VARCHAR2(50 CHAR) NOT NULL,
341 logins NUMBER(10,0) DEFAULT '0' NOT NULL,
342 last_login NUMBER(10,0)
344 ALTER TABLE users ADD CONSTRAINT users_pk PRIMARY KEY(id) ENABLE;
345 CREATE UNIQUE INDEX uniq_username ON users(username);
348 CREATE OR REPLACE TRIGGER ninja_widgets_id_TRG BEFORE INSERT OR UPDATE ON ninja_widgets
351 v_newVal NUMBER(12) := 0;
352 v_incval NUMBER(12) := 0;
354 IF INSERTING AND :new.id IS NULL THEN
355 SELECT ninja_widgets_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
356 -- If this is the first time this table have been inserted into (sequence == 1)
358 --get the max indentity value from the table
359 SELECT NVL(max(id),0) INTO v_newVal FROM ninja_widgets;
360 v_newVal := v_newVal + 1;
361 --set the sequence to that value
363 EXIT WHEN v_incval>=v_newVal;
364 SELECT ninja_widgets_id_SEQ.nextval INTO v_incval FROM dual;
367 --used to emulate LAST_INSERT_ID()
368 --mysql_utilities.identity := v_newVal;
369 -- assign the value from the sequence to emulate the identity column
376 CREATE OR REPLACE TRIGGER recurring_downtime_id_TRG BEFORE INSERT OR UPDATE ON recurring_downtime
379 v_newVal NUMBER(12) := 0;
380 v_incval NUMBER(12) := 0;
382 IF INSERTING AND :new.id IS NULL THEN
383 SELECT recurring_downtime_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
384 -- If this is the first time this table have been inserted into (sequence == 1)
386 --get the max indentity value from the table
387 SELECT NVL(max(id),0) INTO v_newVal FROM recurring_downtime;
388 v_newVal := v_newVal + 1;
389 --set the sequence to that value
391 EXIT WHEN v_incval>=v_newVal;
392 SELECT recurring_downtime_id_SEQ.nextval INTO v_incval FROM dual;
395 --used to emulate LAST_INSERT_ID()
396 --mysql_utilities.identity := v_newVal;
397 -- assign the value from the sequence to emulate the identity column
404 CREATE OR REPLACE TRIGGER scheduled_report_types_id_TRG BEFORE INSERT OR UPDATE ON scheduled_report_types
407 v_newVal NUMBER(12) := 0;
408 v_incval NUMBER(12) := 0;
410 IF INSERTING AND :new.id IS NULL THEN
411 SELECT scheduled_report_types_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
412 -- If this is the first time this table have been inserted into (sequence == 1)
414 --get the max indentity value from the table
415 SELECT NVL(max(id),0) INTO v_newVal FROM scheduled_report_types;
416 v_newVal := v_newVal + 1;
417 --set the sequence to that value
419 EXIT WHEN v_incval>=v_newVal;
420 SELECT scheduled_report_types_id_SEQ.nextval INTO v_incval FROM dual;
423 --used to emulate LAST_INSERT_ID()
424 --mysql_utilities.identity := v_newVal;
425 -- assign the value from the sequence to emulate the identity column
432 CREATE OR REPLACE TRIGGER avail_config_objects_id_TRG BEFORE INSERT OR UPDATE ON avail_config_objects
435 v_newVal NUMBER(12) := 0;
436 v_incval NUMBER(12) := 0;
438 IF INSERTING AND :new.id IS NULL THEN
439 SELECT avail_config_objects_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
440 -- If this is the first time this table have been inserted into (sequence == 1)
442 --get the max indentity value from the table
443 SELECT NVL(max(id),0) INTO v_newVal FROM avail_config_objects;
444 v_newVal := v_newVal + 1;
445 --set the sequence to that value
447 EXIT WHEN v_incval>=v_newVal;
448 SELECT avail_config_objects_id_SEQ.nextval INTO v_incval FROM dual;
451 --used to emulate LAST_INSERT_ID()
452 --mysql_utilities.identity := v_newVal;
453 -- assign the value from the sequence to emulate the identity column
460 CREATE OR REPLACE TRIGGER roles_id_TRG BEFORE INSERT OR UPDATE ON roles
463 v_newVal NUMBER(12) := 0;
464 v_incval NUMBER(12) := 0;
466 IF INSERTING AND :new.id IS NULL THEN
467 SELECT roles_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
468 -- If this is the first time this table have been inserted into (sequence == 1)
470 --get the max indentity value from the table
471 SELECT NVL(max(id),0) INTO v_newVal FROM roles;
472 v_newVal := v_newVal + 1;
473 --set the sequence to that value
475 EXIT WHEN v_incval>=v_newVal;
476 SELECT roles_id_SEQ.nextval INTO v_incval FROM dual;
479 --used to emulate LAST_INSERT_ID()
480 --mysql_utilities.identity := v_newVal;
481 -- assign the value from the sequence to emulate the identity column
488 CREATE OR REPLACE TRIGGER ninja_user_authorization_id_TR BEFORE INSERT OR UPDATE ON ninja_user_authorization
491 v_newVal NUMBER(12) := 0;
492 v_incval NUMBER(12) := 0;
494 IF INSERTING AND :new.id IS NULL THEN
495 SELECT ninja_user_authorization_id_SE.NEXTVAL INTO v_newVal FROM DUAL;
496 -- If this is the first time this table have been inserted into (sequence == 1)
498 --get the max indentity value from the table
499 SELECT NVL(max(id),0) INTO v_newVal FROM ninja_user_authorization;
500 v_newVal := v_newVal + 1;
501 --set the sequence to that value
503 EXIT WHEN v_incval>=v_newVal;
504 SELECT ninja_user_authorization_id_SE.nextval INTO v_incval FROM dual;
507 --used to emulate LAST_INSERT_ID()
508 --mysql_utilities.identity := v_newVal;
509 -- assign the value from the sequence to emulate the identity column
516 CREATE OR REPLACE TRIGGER scheduled_report_periods_id_TR BEFORE INSERT OR UPDATE ON scheduled_report_periods
519 v_newVal NUMBER(12) := 0;
520 v_incval NUMBER(12) := 0;
522 IF INSERTING AND :new.id IS NULL THEN
523 SELECT scheduled_report_periods_id_SE.NEXTVAL INTO v_newVal FROM DUAL;
524 -- If this is the first time this table have been inserted into (sequence == 1)
526 --get the max indentity value from the table
527 SELECT NVL(max(id),0) INTO v_newVal FROM scheduled_report_periods;
528 v_newVal := v_newVal + 1;
529 --set the sequence to that value
531 EXIT WHEN v_incval>=v_newVal;
532 SELECT scheduled_report_periods_id_SE.nextval INTO v_incval FROM dual;
535 --used to emulate LAST_INSERT_ID()
536 --mysql_utilities.identity := v_newVal;
537 -- assign the value from the sequence to emulate the identity column
544 CREATE OR REPLACE TRIGGER users_id_TRG BEFORE INSERT OR UPDATE ON users
547 v_newVal NUMBER(12) := 0;
548 v_incval NUMBER(12) := 0;
550 IF INSERTING AND :new.id IS NULL THEN
551 SELECT users_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
552 -- If this is the first time this table have been inserted into (sequence == 1)
554 --get the max indentity value from the table
555 SELECT NVL(max(id),0) INTO v_newVal FROM users;
556 v_newVal := v_newVal + 1;
557 --set the sequence to that value
559 EXIT WHEN v_incval>=v_newVal;
560 SELECT users_id_SEQ.nextval INTO v_incval FROM dual;
563 --used to emulate LAST_INSERT_ID()
564 --mysql_utilities.identity := v_newVal;
565 -- assign the value from the sequence to emulate the identity column
572 CREATE OR REPLACE TRIGGER sla_periods_id_TRG BEFORE INSERT OR UPDATE ON sla_periods
575 v_newVal NUMBER(12) := 0;
576 v_incval NUMBER(12) := 0;
578 IF INSERTING AND :new.id IS NULL THEN
579 SELECT sla_periods_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
580 -- If this is the first time this table have been inserted into (sequence == 1)
582 --get the max indentity value from the table
583 SELECT NVL(max(id),0) INTO v_newVal FROM sla_periods;
584 v_newVal := v_newVal + 1;
585 --set the sequence to that value
587 EXIT WHEN v_incval>=v_newVal;
588 SELECT sla_periods_id_SEQ.nextval INTO v_incval FROM dual;
591 --used to emulate LAST_INSERT_ID()
592 --mysql_utilities.identity := v_newVal;
593 -- assign the value from the sequence to emulate the identity column
600 CREATE OR REPLACE TRIGGER sla_config_id_TRG BEFORE INSERT OR UPDATE ON sla_config
603 v_newVal NUMBER(12) := 0;
604 v_incval NUMBER(12) := 0;
606 IF INSERTING AND :new.id IS NULL THEN
607 SELECT sla_config_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
608 -- If this is the first time this table have been inserted into (sequence == 1)
610 --get the max indentity value from the table
611 SELECT NVL(max(id),0) INTO v_newVal FROM sla_config;
612 v_newVal := v_newVal + 1;
613 --set the sequence to that value
615 EXIT WHEN v_incval>=v_newVal;
616 SELECT sla_config_id_SEQ.nextval INTO v_incval FROM dual;
619 --used to emulate LAST_INSERT_ID()
620 --mysql_utilities.identity := v_newVal;
621 -- assign the value from the sequence to emulate the identity column
628 CREATE OR REPLACE TRIGGER ninja_settings_id_TRG BEFORE INSERT OR UPDATE ON ninja_settings
631 v_newVal NUMBER(12) := 0;
632 v_incval NUMBER(12) := 0;
634 IF INSERTING AND :new.id IS NULL THEN
635 SELECT ninja_settings_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
636 -- If this is the first time this table have been inserted into (sequence == 1)
638 --get the max indentity value from the table
639 SELECT NVL(max(id),0) INTO v_newVal FROM ninja_settings;
640 v_newVal := v_newVal + 1;
641 --set the sequence to that value
643 EXIT WHEN v_incval>=v_newVal;
644 SELECT ninja_settings_id_SEQ.nextval INTO v_incval FROM dual;
647 --used to emulate LAST_INSERT_ID()
648 --mysql_utilities.identity := v_newVal;
649 -- assign the value from the sequence to emulate the identity column
656 CREATE OR REPLACE TRIGGER scheduled_reports_id_TRG BEFORE INSERT OR UPDATE ON scheduled_reports
659 v_newVal NUMBER(12) := 0;
660 v_incval NUMBER(12) := 0;
662 IF INSERTING AND :new.id IS NULL THEN
663 SELECT scheduled_reports_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
664 -- If this is the first time this table have been inserted into (sequence == 1)
666 --get the max indentity value from the table
667 SELECT NVL(max(id),0) INTO v_newVal FROM scheduled_reports;
668 v_newVal := v_newVal + 1;
669 --set the sequence to that value
671 EXIT WHEN v_incval>=v_newVal;
672 SELECT scheduled_reports_id_SEQ.nextval INTO v_incval FROM dual;
675 --used to emulate LAST_INSERT_ID()
676 --mysql_utilities.identity := v_newVal;
677 -- assign the value from the sequence to emulate the identity column
684 CREATE OR REPLACE TRIGGER sla_config_objects_id_TRG BEFORE INSERT OR UPDATE ON sla_config_objects
687 v_newVal NUMBER(12) := 0;
688 v_incval NUMBER(12) := 0;
690 IF INSERTING AND :new.id IS NULL THEN
691 SELECT sla_config_objects_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
692 -- If this is the first time this table have been inserted into (sequence == 1)
694 --get the max indentity value from the table
695 SELECT NVL(max(id),0) INTO v_newVal FROM sla_config_objects;
696 v_newVal := v_newVal + 1;
697 --set the sequence to that value
699 EXIT WHEN v_incval>=v_newVal;
700 SELECT sla_config_objects_id_SEQ.nextval INTO v_incval FROM dual;
703 --used to emulate LAST_INSERT_ID()
704 --mysql_utilities.identity := v_newVal;
705 -- assign the value from the sequence to emulate the identity column
712 CREATE OR REPLACE TRIGGER user_tokens_id_TRG BEFORE INSERT OR UPDATE ON user_tokens
715 v_newVal NUMBER(12) := 0;
716 v_incval NUMBER(12) := 0;
718 IF INSERTING AND :new.id IS NULL THEN
719 SELECT user_tokens_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
720 -- If this is the first time this table have been inserted into (sequence == 1)
722 --get the max indentity value from the table
723 SELECT NVL(max(id),0) INTO v_newVal FROM user_tokens;
724 v_newVal := v_newVal + 1;
725 --set the sequence to that value
727 EXIT WHEN v_incval>=v_newVal;
728 SELECT user_tokens_id_SEQ.nextval INTO v_incval FROM dual;
731 --used to emulate LAST_INSERT_ID()
732 --mysql_utilities.identity := v_newVal;
733 -- assign the value from the sequence to emulate the identity column
740 CREATE OR REPLACE TRIGGER avail_config_id_TRG BEFORE INSERT OR UPDATE ON avail_config
743 v_newVal NUMBER(12) := 0;
744 v_incval NUMBER(12) := 0;
746 IF INSERTING AND :new.id IS NULL THEN
747 SELECT avail_config_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
748 -- If this is the first time this table have been inserted into (sequence == 1)
750 --get the max indentity value from the table
751 SELECT NVL(max(id),0) INTO v_newVal FROM avail_config;
752 v_newVal := v_newVal + 1;
753 --set the sequence to that value
755 EXIT WHEN v_incval>=v_newVal;
756 SELECT avail_config_id_SEQ.nextval INTO v_incval FROM dual;
759 --used to emulate LAST_INSERT_ID()
760 --mysql_utilities.identity := v_newVal;
761 -- assign the value from the sequence to emulate the identity column
768 CREATE OR REPLACE TRIGGER ninja_db_version_id_TRG BEFORE INSERT OR UPDATE ON ninja_db_version
771 v_newVal NUMBER(12) := 0;
772 v_incval NUMBER(12) := 0;
774 IF INSERTING AND :new.id IS NULL THEN
775 SELECT ninja_db_version_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
776 -- If this is the first time this table have been inserted into (sequence == 1)
778 --get the max indentity value from the table
779 SELECT NVL(max(id),0) INTO v_newVal FROM ninja_db_version;
780 v_newVal := v_newVal + 1;
781 --set the sequence to that value
783 EXIT WHEN v_incval>=v_newVal;
784 SELECT ninja_db_version_id_SEQ.nextval INTO v_incval FROM dual;
787 --used to emulate LAST_INSERT_ID()
788 --mysql_utilities.identity := v_newVal;
789 -- assign the value from the sequence to emulate the identity column
796 CREATE OR REPLACE TRIGGER summary_config_id_TRG BEFORE INSERT OR UPDATE ON summary_config
799 v_newVal NUMBER(12) := 0;
800 v_incval NUMBER(12) := 0;
802 IF INSERTING AND :new.id IS NULL THEN
803 SELECT summary_config_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
804 -- If this is the first time this table have been inserted into (sequence == 1)
806 --get the max indentity value from the table
807 SELECT NVL(max(id),0) INTO v_newVal FROM summary_config;
808 v_newVal := v_newVal + 1;
809 --set the sequence to that value
811 EXIT WHEN v_incval>=v_newVal;
812 SELECT summary_config_id_SEQ.nextval INTO v_incval FROM dual;
815 --used to emulate LAST_INSERT_ID()
816 --mysql_utilities.identity := v_newVal;
817 -- assign the value from the sequence to emulate the identity column
824 CREATE OR REPLACE TRIGGER saved_searches_id_TRG BEFORE INSERT OR UPDATE ON ninja_saved_searches
827 v_newVal NUMBER(12) := 0;
828 v_incval NUMBER(12) := 0;
830 IF INSERTING AND :new.id IS NULL THEN
831 SELECT saved_searches_id_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
832 -- If this is the first time this table have been inserted into (sequence == 1)
834 --get the max indentity value from the table
835 SELECT NVL(max(id),0) INTO v_newVal FROM ninja_saved_searches;
836 v_newVal := v_newVal + 1;
837 --set the sequence to that value
839 EXIT WHEN v_incval>=v_newVal;
840 SELECT saved_searches_id_SEQ.nextval INTO v_incval FROM dual;
843 --used to emulate LAST_INSERT_ID()
844 --mysql_utilities.identity := v_newVal;
845 -- assign the value from the sequence to emulate the identity column