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