Added the class definition for a filesystem parameter.
[gnucomo.git] / src / database / create.sql
1 --*************************************************************************
2 --  (c) Copyright 2002, De Winter Information Solutions
3 -- This is free software; you can redistribute it and/or modify it under the
4 -- terms of the GNU General Public License, see the file COPYING.
5 --*************************************************************************/
6 --
7 -- Gnucomo database creation script.
8 --
9 --
10 -- This SQL script creates the initial tables for the Gnucomo database.
11 -- Before running this script with 'psql -f', you should have your
12 -- DBA create the database and give access permissions.
13 --
14 --  $Log: create.sql,v $
15 --  Revision 1.22  2007-11-03 10:30:10  arjen
16 --  Added the class definition for a filesystem parameter.
17 --  New issue type: 'property out of range'.
18 --
19 --  Revision 1.21  2007/10/23 11:25:42  arjen
20 --  Fixed the Failure and warning issues.
21 --
22 --  Revision 1.20  2007/01/11 13:47:35  arjen
23 --  Log_adv and derived tables removed.
24 --  Create notifications from log entries with pattern matching.
25 --
26 --  Revision 1.19  2005/06/04 07:09:47  arjen
27 --  - Fixed field declaration for PostgreSQL 7.4
28 --  - New tables: log_abuse, object_abuse and service_pattern
29 --  - Added general service patterns in the service 'ANY'
30 --  - Added new issue types.
31 --
32 --  Revision 1.18  2003/12/03 08:06:57  arjen
33 --  Changed the type of log_adv_daemon_email.delay and log_adv_daemon_email.xdelay
34 --  from time to interval. These delays can be more than 24 hours.
35 --
36 --  Revision 1.17  2003/09/02 12:49:47  arjen
37 --  BUGFIX: Secondary indices on log_notification were unique.
38 --  Additional information in the 'usr' table: 'display_name' and 'email'.
39 --  Added new issues and services.
40 --
41 --  Revision 1.16  2003/08/16 14:29:02  arjen
42 --  Fixed a few typos.
43 --
44 --  Revision 1.15  2003/08/05 07:43:24  arjen
45 --  Added index to the history table.
46 --
47 --  Revision 1.14  2003/07/09 07:14:59  arjen
48 --  New database tables: notification_check, notification_check_buffer,
49 --  notification_check_line and object_statistics.
50 --
51 --  Revision 1.13  2003/03/29 08:27:05  arjen
52 --  New columns in the table 'log_adv_daemon_email': size, pri, relay,
53 --  status_details and dsn.
54 --  Added several indices for the table 'log_adv_daemon_email'.
55 --
56 --  Revision 1.12  2003/02/21 08:38:38  arjen
57 --  Added new table to the database: log_adv_daemon_email.
58 --
59 --  Revision 1.11  2003/02/16 08:24:38  arjen
60 --  Added a new entry to the action table: Notification was displayed in the listing
61 --
62 --  Revision 1.10  2003/02/14 06:32:27  arjen
63 --  Setup the groups and database permissions. The three groups
64 --  are: view, ops and admin.
65 --  Added a new entry to the action table.
66 --
67 --  Revision 1.9  2003/02/13 08:46:54  arjen
68 --  Added log, notification and parameter counters to the 'object' table.
69 --  Counting these things at the time a user interface needs them is
70 --  too slow. Other programs, like gcm_daemon en gcm_input should prepare
71 --  these counters for quick retrieval.
72 --
73 --  Revision 1.8  2003/02/08 07:36:41  arjen
74 --  Added new table to the database : log_adv_daemon
75 --
76 --  Revision 1.7  2003/02/05 09:29:08  arjen
77 --  Bug fix: action.statuscode was in upper case.
78 --
79 --  Revision 1.6  2003/01/20 07:29:48  arjen
80 --  Added new tables to the database: parameter_class and parameter_notification
81 --
82 --  Revision 1.5  2003/01/18 08:46:48  arjen
83 --  Added new records to the 'type_of_issue' table.
84 --  Changed semantics of actionid 9 in the 'action' table.
85 --
86 --
87
88 CREATE SEQUENCE "action_actionid_seq";
89
90 CREATE TABLE "action"
91 (
92         "actionid" bigint DEFAULT nextval('"action_actionid_seq"'::text) NOT NULL,
93         "actionname" text,
94         "statuscode" character varying(3),
95         "description" text
96 );
97
98
99 COPY "action" FROM stdin;
100 1       Entry in the system     new     This indicates that a notification has been entered into the system.
101 2       Display to user opn     The notification has been displayed to the user. It doesn't mean that the user actually read the notification, but he/she should be aware. For that reason we consider the notification to be OPEN
102 3       Remarks added   pen     Remarks have been added to the notification.
103 4       Priority changed manually       pen     The priority of the notification has been changed by the user.
104 5       Priority changed automatically  pen     The priority of the notification has been changed by the system. This can be the result of an action by the user or an automatical escalation.
105 6       Action taken    pen     An action has been taken.
106 7       Assignment to user      pen     The notification has been assigned to an user.
107 8       More information or research needed.    inv     The notification is relevant and will be handled, however more information or research will be needed. For that reason the status has been altered to UNDER INVESTIGATION.
108 9       Investigation completed pen     Investigation has been done. Information is available to fix the problem.
109 10      Job output no longer valid      cls     By making a newer job output a valid reference, this data has been obsoleted. Since it was a reference once the output isn't interesting anymore and thus the notification can be closed.
110 11      Action taken - please verify    cls     An action has been taken and things should have been resolved. Before the notification can be closed a verification has to be done. The new status is now VERIFY.
111 12      Action not verified     pen     A check has been done and the results were not good. New verification is needed. The status has been changed back to PEN.
112 13      Action verified cls     A check has been done and the results were approved. The notification has been closed.
113 15      SMS sent        opn     An SMS has been sent.
114 14      E-mail sent     opn     An e-mail has been sent.
115 16      Fax sent        opn     An fax has been sent.
116 17      Log entries shown       \N      The log entries relevant to the notification have been shown.
117 18      Notification closed     cls     The notification has been closed.
118 19      Notification reopend    opn     The notification has been reopend.
119 20      Redisplayed to user     \N      The notification has been presented to a user. This is not the first time
120 21      Displayed in list       \N      The notification has been presented in a list with other notifications.
121 \.
122
123 CREATE UNIQUE INDEX action_actionid_key ON "action" USING btree (actionid);
124
125 CREATE UNIQUE INDEX act_pk ON "action" USING btree (actionid);
126
127 CREATE UNIQUE INDEX act_actionname ON "action" USING btree (actionname);
128
129 CREATE INDEX act_statuscode ON "action" USING btree (statuscode);
130
131 SELECT setval ('"action_actionid_seq"', 21, true);
132
133 --
134 --
135
136 CREATE SEQUENCE "action_user_actionstepid_seq";
137
138 CREATE TABLE "action_user"
139 (
140         "actionstepid" bigint DEFAULT
141             nextval('"action_user_actionstepid_seq"'::text) NOT NULL,
142         "actionid" bigint,
143         "username" text,
144         "notificationid" bigint,
145         "timestamp" timestamp with time zone,
146         "statuscode" character varying(3),
147         "remarks" text
148 );
149
150 CREATE UNIQUE INDEX action_user_actionstepid_key ON action_user USING btree (actionstepid);
151
152 CREATE INDEX anu_actionid ON action_user USING btree (actionid);
153
154 CREATE INDEX anu_username ON action_user USING btree (username);
155
156 CREATE INDEX anu_notificationid ON action_user USING btree (notificationid);
157
158 CREATE INDEX anu_timestamp ON action_user USING btree ("timestamp");
159
160 CREATE INDEX anu_statuscode ON action_user USING btree (statuscode);
161
162 SELECT setval ('"action_user_actionstepid_seq"', 1, false);
163
164 --
165 --
166
167 CREATE TABLE "db_value"
168 (
169         "setting" text,
170         "setting_value" text
171 );
172
173
174 COPY "db_value" FROM stdin;
175 db_version      48
176 gcm_daemon_version      5
177 log_processing  0
178 last_notification       0
179 \.
180
181 --
182 --
183
184 CREATE TABLE "history"
185 (
186    paramid            bigint,
187    modified           timestamp,
188    change_nature      text,       --  CREATED, MODIFIED or REMOVED
189    changed_property   text,
190    new_value          text,
191    remark             text
192
193 );
194
195 CREATE INDEX history_pid_mod  ON history(paramid, modified);
196
197 --
198 --
199
200 CREATE SEQUENCE "log_logid_seq";
201
202 CREATE TABLE "log"
203 (
204         "logid" bigint DEFAULT nextval('"log_logid_seq"'::text) NOT NULL,
205         "objectid" bigint,
206         "original_filename" text,
207         "servicecode" text,
208         "object_timestamp" timestamp with time zone,
209         "timestamp" timestamp with time zone,
210         "rawdata" text,
211         "processed" boolean DEFAULT false,
212         "recognized" boolean DEFAULT false
213 );
214
215 CREATE UNIQUE INDEX log_logid_key ON log USING btree (logid);
216
217 CREATE INDEX log_objectid ON log USING btree (objectid);
218
219 CREATE INDEX log_original_filename ON log USING btree (original_filename);
220
221 CREATE INDEX log_servicecode ON log USING btree (servicecode);
222
223 CREATE INDEX log_object_timestmap ON log USING btree ("timestamp");
224
225 CREATE INDEX log_timestmap ON log USING btree ("timestamp");
226
227 CREATE INDEX log_timestamp ON log USING btree (object_timestamp);
228
229 CREATE INDEX log_processed ON log USING btree (processed);
230
231 SELECT setval ('"log_logid_seq"', 1, false);
232
233
234 CREATE TABLE log_abuse
235 (
236         logid      bigint,
237         objectid   bigint,
238         source     inet
239 );
240
241 --
242 --
243
244 CREATE TABLE "log_notification"
245 (
246         "notificationid" bigint,
247         "logid" bigint
248 );
249
250 CREATE UNIQUE INDEX lon_pk ON log_notification USING btree (notificationid, logid);
251
252 CREATE INDEX lon_notificationid ON log_notification USING btree (notificationid);
253
254 CREATE INDEX lon_logid ON log_notification USING btree (logid);
255
256 --
257 --
258
259 CREATE SEQUENCE "notification_notificationid_seq";
260
261 CREATE TABLE "notification"
262 (
263         "notificationid" bigint DEFAULT
264             nextval('"notification_notificationid_seq"'::text) NOT NULL,
265         "objectid" bigint,
266         "type_of_issueid" bigint,
267         "timestamp" timestamp with time zone,
268         "statuscode" character varying(3),
269         "priority" integer,
270         "escalation_count_timestamp" timestamp with time zone,
271         "repeat_notification_timestamp" timestamp with time zone,
272         "securitylevel_view" integer,
273         "securitylevel_add" integer,
274         "securitylevel_close" integer
275 );
276
277 CREATE UNIQUE INDEX notification_notificationid_key ON notification USING btree (notificationid);
278
279 CREATE INDEX not_objectid ON notification USING btree (objectid);
280
281 CREATE INDEX not_type_of_issueid ON notification USING btree (type_of_issueid);
282
283 CREATE INDEX not_timestamp ON notification USING btree ("timestamp");
284
285 CREATE INDEX not_statuscode ON notification USING btree (statuscode);
286
287 CREATE INDEX not_priority ON notification USING btree (priority);
288
289 CREATE INDEX not_escalation_count_timestamp ON notification USING btree (escalation_count_timestamp);
290
291 CREATE INDEX not_repeat_notification_timesta ON notification USING btree (repeat_notification_timestamp);
292
293 SELECT setval ('"notification_notificationid_seq"', 1, false);
294
295 --
296 --
297
298 CREATE SEQUENCE checkid_seq;
299     
300 CREATE TABLE notification_check
301 (
302      checkid                 bigint DEFAULT nextval('checkid_seq'::text) NOT NULL,
303      checkname               TEXT,
304      description             TEXT,
305      time_between_executions INTERVAL, 
306      last_execution          timestamp,
307      execution_counter       BIGINT,
308      notificationcounter     BIGINT,
309      decreasinglist          BOOLEAN default false,
310      type_of_issueid         BIGINT
311 );
312
313 CREATE UNIQUE INDEX not_check_checkid ON notification_check (checkid);
314
315 CREATE UNIQUE INDEX not_check_checkname ON notification_check (checkname);
316
317 CREATE INDEX not_check_check_lastexec ON notification_check (last_execution);
318
319 --
320 --
321
322 CREATE TABLE notification_check_buffer
323 (
324     checkid     BIGINT,
325     sortorder   INTEGER,
326     pid         INTEGER,
327     logid       bigint
328 );
329
330 CREATE INDEX notcheckbuffer_checkid ON notification_check_buffer(checkid);
331      
332 CREATE INDEX notcheckbuffer_sort ON notification_check_buffer(sortorder);
333
334 CREATE INDEX notcheckbuffer_pid ON notification_check_buffer(pid);
335      
336 CREATE INDEX notcheckbuffer_logid ON notification_check_buffer(logid);
337
338 --
339 --
340
341 CREATE SEQUENCE checklineid_seq;
342      
343 CREATE TABLE notification_check_line
344 (
345     checklineid             BIGINT DEFAULT nextval('checklineid_seq'::text) NOT NULL,
346     checkid                 BIGINT,
347     sortorder               INTEGER,
348     last_logid              BIGINT default 0,
349     historicboundary        INTERVAL default '0',
350     use_logid               BOOLEAN default false,
351     sql_query               TEXT
352 );
353      
354 CREATE UNIQUE INDEX notcheckline_checklineid ON notification_check_line (checklineid);
355
356 CREATE INDEX notcheckline_checkid            ON notification_check_line (checkid);
357
358 CREATE INDEX notcheckline_sort               ON notification_check_line (sortorder);
359
360 CREATE INDEX notcheckline_check_sort         ON notification_check_line (checkid, sortorder);
361
362 --
363 --
364
365 CREATE SEQUENCE "object_objectid_seq";
366
367 CREATE TABLE "object"
368 (
369         "objectid" bigint DEFAULT nextval('"object_objectid_seq"'::text) NOT NULL,
370         "objectname" text,
371         "objectcode" text,
372         "scp_enabled" boolean,
373         "scp_inet" inet,
374         "mail_enabled" boolean,
375         "mail_from" text,
376         "sms_enabled" boolean,
377         "sms_number" text,
378         "fax_enabled" boolean,
379         "fax_number" text,
380         "object_description" text,
381         "object_owner" text,
382         "physical_location" text,
383         "timezone" text,
384         "remark" text,
385         "os"     text,
386         "os_version"   text,
387         "log_count"    bigint,
388         "notification_count"   bigint,
389         "parameter_count"      bigint
390 );
391
392 CREATE UNIQUE INDEX object_objectid_key ON object USING btree (objectid);
393
394 CREATE UNIQUE INDEX obj_objectname ON object USING btree (objectname);
395
396 CREATE UNIQUE INDEX obj_objectcode ON object USING btree (objectcode);
397
398 CREATE INDEX obj_mail_from ON object USING btree (mail_from);
399
400 CREATE INDEX os ON object (os);
401
402 CREATE INDEX os_version ON object (os, os_version);
403
404 SELECT setval ('"object_objectid_seq"', 1, false);
405
406 --
407 --
408
409 CREATE TABLE "object_abuse"
410 (
411         objectid   bigint,
412         source     inet,
413         nr_abuses  integer,
414         status     text,
415         last_change   timestamp,
416
417         primary key (objectid, source)
418 );
419
420 --
421 --
422
423 CREATE TABLE "object_issue"
424 (
425         "objectid" bigint,
426         "type_of_issueid" bigint,
427         "default_priority" integer,
428         "escalation" boolean,
429         "escalation_time" time without time zone,
430         "max_priority" integer,
431         "adjust_setting" text
432 );
433
434 CREATE UNIQUE INDEX obj_pk ON object_issue USING btree (objectid, type_of_issueid);
435
436 CREATE INDEX obj_objectid ON object_issue USING btree (objectid);
437
438 CREATE UNIQUE INDEX obj_type_of_notificationid ON object_issue USING btree (type_of_issueid);
439
440 --
441 --
442
443 CREATE TABLE "object_priority"
444 (
445         "objectid" bigint,
446         "priorityid" integer,
447         "send_mail" boolean,
448         "send_sms" boolean,
449         "send_fax" boolean,
450         "repeat_notification" boolean,
451         "interval_for_repeat" time without time zone
452 );
453
454 CREATE UNIQUE INDEX obi_pk ON object_priority USING btree (objectid, priorityid);
455
456 CREATE INDEX obi_objectid ON object_priority USING btree (objectid);
457
458 CREATE INDEX obi_priorityid ON object_priority USING btree (priorityid);
459
460 --
461 --
462
463 CREATE TABLE "object_service"
464 (
465         "objectid" bigint,
466         "servicecode" text,
467         "expected_interval" bigint,
468         "last_entry" timestamp with time zone,
469         "default_priority" integer,
470         "maximum_priority" integer,
471         "accepted" boolean
472 );
473
474 CREATE UNIQUE INDEX obs_pk ON object_service USING btree (objectid, servicecode);
475
476 CREATE INDEX obs_objectid ON object_service USING btree (objectid);
477
478 CREATE INDEX obs_servicecode ON object_service USING btree (servicecode);
479
480 CREATE INDEX obs_accepted ON object_service USING btree (accepted);
481
482 --
483 --
484
485 CREATE TABLE object_statistics
486 (
487     objectid       bigint,
488     statname       text,
489     statvalue      double precision,
490
491     primary key (objectid, statname)
492 );
493
494 CREATE INDEX obj_stat_objid ON object_statistics USING btree (objectid);
495
496 --
497 --
498
499 CREATE TABLE "object_user"
500 (
501         "objectid" bigint,
502         "username" text,
503         "security_level" integer
504 );
505
506 CREATE UNIQUE INDEX ous_pk ON object_user USING btree (objectid, username);
507
508 CREATE INDEX ous_objectid ON object_user USING btree (objectid);
509
510 CREATE INDEX ous_username ON object_user USING btree (username);
511
512 CREATE INDEX ous_security_level ON object_user USING btree (security_level);
513
514 --
515 --
516
517 CREATE SEQUENCE "paramid_seq";
518
519 CREATE TABLE "parameter"
520 (
521         "paramid" bigint DEFAULT nextval('"paramid_seq"'::text) NOT NULL,
522         "objectid" bigint,
523         "name" text,
524         "class" text,
525         "description" text,
526
527         primary key (paramid)
528 );
529
530 CREATE UNIQUE INDEX param_obj_name ON parameter USING btree (objectid, name, class);
531
532 SELECT setval ('"paramid_seq"', 1, true);
533
534 --
535 --
536
537 CREATE TABLE "parameter_class"
538 (
539    "name"             text,     --  Name of the class: see parameter.class
540    "property_name"    text,
541    "description"      text,
542    "property_type"    text,     --  STATIC or DYNAMIC
543    "min"              float,    --  Default minimum value
544    "max"              float,    --  Default maximum value
545    "notify"           boolean,  --  Notify if something changes ?
546
547    primary key (name, property_name)
548 );
549
550 INSERT INTO parameter_class (name, property_name, description, property_type, notify)
551   VALUES ('package', 'version', 'The installed version of the package', 'STATIC', 't');
552
553 INSERT INTO parameter_class (name, property_name, description, property_type, notify)
554   VALUES ('filesystem', 'device', 'Volume on which the filesystem resides', 'STATIC', 't');
555 INSERT INTO parameter_class (name, property_name, description, property_type, notify)
556   VALUES ('filesystem', 'size', 'Total size in kilobytes', 'STATIC', 't');
557 INSERT INTO parameter_class (name, property_name, description, property_type, min, max, notify)
558   VALUES ('filesystem', 'used', 'Number of kilobytes used', 'DYNAMIC', 0, 1000000, 't');
559 INSERT INTO parameter_class (name, property_name, description, property_type, min, max, notify)
560   VALUES ('filesystem', 'available', 'Number of kilobytes available', 'DYNAMIC', 1000, 1000000, 't');
561 INSERT INTO parameter_class (name, property_name, description, property_type, notify)
562   VALUES ('filesystem', 'Inodes', 'Total number of i-nodes', 'STATIC', 't');
563 INSERT INTO parameter_class (name, property_name, description, property_type, min, max, notify)
564   VALUES ('filesystem', 'Iused', 'Number of i-nodes used', 'DYNAMIC', 0, 1000000, 't');
565 INSERT INTO parameter_class (name, property_name, description, property_type, min, max, notify)
566   VALUES ('filesystem', 'Ifree', 'Number of i-nodes available', 'DYNAMIC', 1000, 1000000, 't');
567
568 --
569 --
570
571 CREATE TABLE "parameter_notification"
572 (
573    "notificationid" bigint,
574    "paramid"        bigint,
575
576    primary key (notificationid, paramid)
577 );
578
579 --
580 --
581
582 CREATE TABLE "priority"
583 (
584         "priority" integer,
585         "send_mail" boolean,
586         "send_sms" boolean,
587         "send_fax" boolean,
588         "repeat_notification" boolean,
589         "interval_for_repeat" time without time zone
590 );
591
592
593 CREATE UNIQUE INDEX pri_pk ON priority USING btree (priority);
594
595 --
596 --
597
598 CREATE TABLE "property"
599 (
600    paramid bigint,
601    name    text,
602    value   text,
603    type    text,   --   STATIC or DYNAMIC
604    min     float,
605    max     float,
606
607    primary key (paramid, name)
608 );
609
610 --
611 --
612
613 CREATE TABLE "service"
614 (
615         "servicecode" text,
616         "servicename" text,
617         "default_priority" integer,
618         "max_priority" integer
619 );
620
621 COPY "service" FROM stdin;
622 httpd   httpd   1       5
623 imap    imap    1       5
624 imapd   imapd   1       5
625 kernel  kernel  1       5
626 sshd    sshd    1       5
627 su      su      1       5
628 syslogd syslogd 1       5
629 CROND   Cron Daemon     1       5
630 gnucomo Gnucomo Daemon  1       5
631 sendmail        Mail Transport Agent    1       5
632 dhcpd   DHCP Daemon     1       5
633 rpc     NFS Services    1       5
634 named   DNS Services    1       5
635 xinetd  Internet Daemon 1       5
636 ipop    Post Office Protocol    1       5
637 mgetty  Serial port login and fax       1       5
638 login   User login      1       5
639 pam     Authentication modules  1       5
640 modprobe        Kernel modules  1       5
641 \.
642
643 CREATE UNIQUE INDEX ser_pk ON service USING btree (servicecode);
644
645 CREATE UNIQUE INDEX ser_servicename ON service USING btree (servicename);
646
647 CREATE TABLE service_pattern
648 (
649       service   text,
650       rank      int,
651       pattern   text,
652       action    text,
653       argument  text,
654
655       primary key (service, rank)
656 );
657
658 INSERT INTO service_pattern VALUES ('ANY', 999999, '.+', 'notify', 'unmatched log');
659 INSERT INTO service_pattern VALUES ('ANY', 999990, '[Ee][Rr][Rr][Oo][Rr]', 'notify', 'Error detected');
660 INSERT INTO service_pattern VALUES ('ANY', 999991, '[Ff][Aa][Ii][Ll]', 'notify', 'Failure detected');
661 INSERT INTO service_pattern VALUES ('ANY', 999992, '[Ww][Aa][Rr][Nn]', 'notify', 'Warning detected');
662
663 --
664
665 CREATE TABLE "status"
666 (
667         "statuscode" character varying(3),
668         "statusname" text,
669         "open_notification" boolean,
670         "description" text
671 );
672
673
674 COPY "status" FROM stdin;
675 new     new entry       t       Just detected, but nothing has been done yet
676 opn     open notification       t       The notification has been displayed to a user or a user has been notified. However nothing has been done yet.
677 pen     pending t       The notification is currently being worked on.
678 ver     waiting for verification        t       The notification has been worked on and is currently awaiting the approval/verification.
679 rej     rejected        f       The notification has been identified as a false postive and was reject. The notification is now closed
680 cls     closed  f       The notification has been closed
681 inv     needs investigation     t       The notification is currently under investigation and is awaiting additional details before one can work on this again.
682 \.
683
684 CREATE UNIQUE INDEX sta_pk ON status USING btree (statuscode);
685
686 CREATE UNIQUE INDEX sta_statusname ON status USING btree (statusname);
687
688 CREATE INDEX sta_open_notification ON status USING btree (open_notification);
689
690 --
691 --
692
693 CREATE TABLE supported_os
694 (
695     os_name text,
696     remarks text
697 );
698
699 CREATE UNIQUE INDEX spp_os ON supported_os (os_name);
700
701 --
702 --
703
704 CREATE SEQUENCE "type_of_issue_type_of_issue_seq";
705
706 CREATE TABLE "type_of_issue"
707 (
708         "type_of_issueid" bigint DEFAULT
709            nextval('"type_of_issue_type_of_issue_seq"'::text) NOT NULL,
710         "name" text,
711         "suggested_priority" text,
712         "description" text,
713         "active" boolean,
714         automated_check       boolean,
715         alert_level           int,
716         last_run              timestamp,
717         recheck_interval      timestamp
718 );
719
720
721 COPY "type_of_issue" FROM stdin;
722 1       manual entry    4       A manual entry of a notification        t       t       1       \N      \N
723 2       parameter created       3       A new parameter was created     t       t       1       \N      \N
724 3       property modified       3       The STATIC property of a parameter was modified t       t       1       \N      \N
725 4       parameter removed       3       A parameter was removed t       t       1       \N      \N
726 5       service unknown 5       Service in log entry is unknown t       t       1       \N      \N
727 6       service not used        5       Service in log entry is not used        t       t       1       \N      \N
728 7       abuses exceeded 5       Abuse treshold exceeded from an IP address      t       t       1       \N      \N
729 8       unmatched log   5       Log entries could not be matched        t       t       1       \N      \N
730 9       Error detected  5       An Error is reported in the log t       t       1       \N      \N
731 10      Failure detected        5       A Failure is reported in the log        t       t       1       \N      \N
732 11      Warning detected        3       A Warning is reported in the log        t       t       1       \N      \N
733 12      property out of range   5       The DYNAMIC property of a parameter is out of range     t       t       1       \N      \N
734 \.
735
736 CREATE UNIQUE INDEX type_of_issue_type_of_issue_key ON type_of_issue USING btree (type_of_issueid);
737
738 CREATE UNIQUE INDEX toi_name ON type_of_issue USING btree (name);
739
740 CREATE INDEX toi_active ON type_of_issue USING btree (active);
741
742 SELECT setval ('"type_of_issue_type_of_issue_seq"', 12, true);
743
744 --
745 --
746
747 CREATE TABLE "usr"
748 (
749         "username" text NOT NULL,
750         "active_sessionid" bigint,
751         "account_active" boolean,
752         "security_level" integer,
753         display_name     text,
754         email            text
755 );
756
757 CREATE UNIQUE INDEX usr_username ON usr USING btree (username);
758
759 CREATE UNIQUE INDEX usr_active_sessionid ON usr USING btree (active_sessionid);
760
761 CREATE INDEX usr_account_active ON usr USING btree (account_active);
762
763 CREATE INDEX usr_security_level ON usr USING btree (security_level);
764
765 --
766 --  Set up user groups and grant permissions in the proper places.
767
768 CREATE GROUP view;
769 CREATE GROUP ops;
770 CREATE GROUP admin;
771
772 GRANT SELECT ON action TO GROUP view, GROUP ops, GROUP admin;
773 GRANT SELECT ON action_user TO GROUP view, GROUP ops, GROUP admin;
774 GRANT SELECT ON db_value TO GROUP view, GROUP ops, GROUP admin;
775 GRANT SELECT ON history TO GROUP view, GROUP ops, GROUP admin;
776 GRANT SELECT ON log TO GROUP view, GROUP ops, GROUP admin;
777 GRANT SELECT ON log_notification TO GROUP view, GROUP ops, GROUP admin;
778 GRANT SELECT ON notification TO GROUP view, GROUP ops, GROUP admin;
779 GRANT SELECT ON object TO GROUP view, GROUP ops, GROUP admin;
780 GRANT SELECT ON object_abuse TO GROUP view, GROUP ops, GROUP admin;
781 GRANT SELECT ON object_issue TO GROUP view, GROUP ops, GROUP admin;
782 GRANT SELECT ON object_priority TO GROUP view, GROUP ops, GROUP admin;
783 GRANT SELECT ON object_service TO GROUP view, GROUP ops, GROUP admin;
784 GRANT SELECT ON object_statistics TO GROUP view, GROUP ops, GROUP admin;
785 GRANT SELECT ON object_user TO GROUP view, GROUP ops, GROUP admin;
786 GRANT SELECT ON parameter TO GROUP view, GROUP ops, GROUP admin;
787 GRANT SELECT ON parameter_class TO GROUP view, GROUP ops, GROUP admin;
788 GRANT SELECT ON parameter_notification TO GROUP view, GROUP ops, GROUP admin;
789 GRANT SELECT ON priority TO GROUP view, GROUP ops, GROUP admin;
790 GRANT SELECT ON property TO GROUP view, GROUP ops, GROUP admin;
791 GRANT SELECT ON service TO GROUP view, GROUP ops, GROUP admin;
792 GRANT SELECT ON status TO GROUP view, GROUP ops, GROUP admin;
793 GRANT SELECT ON supported_os TO GROUP view, GROUP ops, GROUP admin;
794 GRANT SELECT ON type_of_issue TO GROUP view, GROUP ops, GROUP admin;
795 GRANT SELECT ON usr TO GROUP view, GROUP ops, GROUP admin;
796
797 GRANT INSERT ON action_user TO GROUP ops, GROUP admin;
798 GRANT UPDATE ON action_user_actionstepid_seq TO GROUP ops, GROUP admin;
799 GRANT UPDATE ON notification TO GROUP ops, GROUP admin;
800 GRANT INSERT ON object TO GROUP admin;
801 GRANT UPDATE ON object TO GROUP ops, GROUP admin;
802 GRANT DELETE ON object TO GROUP admin;
803 GRANT INSERT ON object_abuse TO GROUP admin;
804 GRANT UPDATE ON object_abuse TO GROUP ops, GROUP admin;
805 GRANT DELETE ON object_abuse TO GROUP admin;
806 GRANT UPDATE ON usr TO GROUP view, GROUP ops, GROUP admin;
807 GRANT INSERT ON usr TO GROUP admin;
808 GRANT DELETE ON usr TO GROUP admin;
809 GRANT SELECT ON service_pattern TO GROUP view, GROUP ops, GROUP admin;
810 GRANT INSERT ON service_pattern TO GROUP admin;
811 GRANT UPDATE ON service_pattern TO GROUP ops, GROUP admin;
812 GRANT DELETE ON service_pattern TO GROUP admin;
813 GRANT SELECT ON log_abuse TO GROUP view, GROUP ops, GROUP admin;