1c575b6f3b658d447afb2dde273617cd67aed32f
[public/netxms.git] / sql / schema.in
1 /*
2 ** NetXMS Database Schema
3 **
4 ** ex: syntax=sql ts=2 sw=2 expandtab
5 */
6
7 /*
8 ** Metadata
9 */
10 CREATE TABLE metadata
11 (
12 var_name varchar(63) not null,
13 var_value varchar(255) not null,
14 PRIMARY KEY(var_name)
15 ) TABLE_TYPE;
16
17 /*
18 ** System configuration table
19 */
20 CREATE TABLE config
21 (
22 var_name varchar(63) not null,
23 var_value varchar(2000) null,
24 #ifdef DB_ORACLE
25 is_visible integer default 1 not null,
26 need_server_restart integer default 0 not null,
27 data_type char(1) default 'S' not null,
28 is_public char(1) default 'N' not null,
29 #else
30 is_visible integer not null default 1,
31 need_server_restart integer not null default 0,
32 data_type char(1) not null default 'S',
33 is_public char(1) not null default 'N',
34 #endif
35 description varchar(450) null,
36 possible_values SQL_TEXT null,
37 PRIMARY KEY(var_name)
38 ) TABLE_TYPE;
39
40 /*
41 ** System configuration data (for large data)
42 */
43 CREATE TABLE config_clob
44 (
45 var_name varchar(63) not null,
46 var_value SQL_TEXT null,
47 PRIMARY KEY(var_name)
48 ) TABLE_TYPE;
49
50 /*
51 ** System configuration possible values
52 */
53 CREATE TABLE config_values
54 (
55 var_name varchar(63) not null,
56 var_value varchar(15) not null,
57 var_description varchar(255) null,
58 PRIMARY KEY(var_name,var_value)
59 ) TABLE_TYPE;
60
61 /*
62 ** Users
63 */
64 CREATE TABLE users
65 (
66 id integer not null,
67 guid varchar(36) not null,
68 name varchar(63) not null,
69 password varchar(127) not null,
70 system_access SQL_INT64 not null,
71 flags integer not null,
72 full_name varchar(127) null,
73 description varchar(255) null,
74 grace_logins integer not null,
75 auth_method integer not null,
76 cert_mapping_method integer not null,
77 cert_mapping_data SQL_TEXT null,
78 auth_failures integer not null,
79 last_passwd_change integer not null,
80 min_passwd_length integer not null,
81 disabled_until integer not null,
82 last_login integer not null,
83 password_history SQL_TEXT null,
84 xmpp_id varchar(127) null,
85 ldap_dn SQL_TEXT null,
86 ldap_unique_id varchar(64) null,
87 PRIMARY KEY(id)
88 ) TABLE_TYPE;
89
90 /*
91 ** User groups
92 */
93
94 CREATE TABLE user_groups
95 (
96 id integer not null,
97 guid varchar(36) not null,
98 name varchar(63) not null,
99 system_access SQL_INT64 not null,
100 flags integer not null,
101 description varchar(255),
102 ldap_dn SQL_TEXT null,
103 ldap_unique_id varchar(64) null,
104 PRIMARY KEY(id)
105 ) TABLE_TYPE;
106
107 /*
108 ** Users to groups mapping
109 */
110
111 CREATE TABLE user_group_members
112 (
113 group_id integer not null,
114 user_id integer not null,
115 PRIMARY KEY(group_id,user_id)
116 ) TABLE_TYPE;
117
118 /*
119 ** User profiles
120 */
121
122 CREATE TABLE user_profiles
123 (
124 user_id integer not null,
125 var_name varchar(255) not null,
126 var_value SQL_TEXT not null,
127 PRIMARY KEY(user_id,var_name)
128 ) TABLE_TYPE;
129
130 /*
131 ** Custom attributes for user database objects
132 */
133
134 CREATE TABLE userdb_custom_attributes
135 (
136 object_id integer not null,
137 attr_name varchar(255) not null,
138 attr_value SQL_TEXT not null,
139 PRIMARY KEY(object_id,attr_name)
140 ) TABLE_TYPE;
141
142 /*
143 ** Common object properties
144 */
145
146 CREATE TABLE object_properties
147 (
148 object_id integer not null,
149 guid varchar(36) not null,
150 name varchar(63) not null,
151 status integer not null,
152 is_deleted integer not null,
153 is_system integer not null,
154 last_modified integer not null,
155 inherit_access_rights integer not null,
156 status_calc_alg integer not null,
157 status_prop_alg integer not null,
158 status_fixed_val integer not null,
159 status_shift integer not null,
160 status_translation varchar(8) not null,
161 status_single_threshold integer not null,
162 status_thresholds varchar(8) not null,
163 comments SQL_TEXT null,
164 location_type integer not null,
165 latitude varchar(20),
166 longitude varchar(20),
167 location_accuracy integer not null,
168 location_timestamp integer not null,
169 image varchar(36) not null,
170 submap_id integer not null,
171 country varchar(63) null,
172 city varchar(63) null,
173 street_address varchar(255) null,
174 postcode varchar(31) null,
175 maint_mode char(1) not null,
176 maint_event_id SQL_INT64 not null,
177 PRIMARY KEY(object_id)
178 ) TABLE_TYPE;
179
180 /**
181 * Object URLs
182 */
183 CREATE TABLE object_urls
184 (
185 object_id integer not null,
186 url_id integer not null,
187 url varchar(2000) null,
188 description varchar(2000) null,
189 PRIMARY KEY(object_id,url_id)
190 ) TABLE_TYPE;
191
192 /*
193 ** Object custom attributes
194 */
195 CREATE TABLE object_custom_attributes
196 (
197 object_id integer not null,
198 attr_name varchar(127) not null,
199 attr_value SQL_TEXT null,
200 PRIMARY KEY(object_id,attr_name)
201 ) TABLE_TYPE;
202
203 CREATE INDEX idx_ocattr_oid ON object_custom_attributes(object_id);
204
205 /*
206 ** Zone objects
207 */
208 CREATE TABLE zones
209 (
210 id integer not null, // Zone object ID
211 zone_guid integer not null, // Globally unique ID for zone
212 proxy_node integer not null,
213 PRIMARY KEY(id)
214 ) TABLE_TYPE;
215
216 /*
217 ** Mobile device objects
218 */
219 CREATE TABLE mobile_devices
220 (
221 id integer not null,
222 device_id varchar(64) not null,
223 vendor varchar(64) null,
224 model varchar(128) null,
225 serial_number varchar(64) null,
226 os_name varchar(32) null,
227 os_version varchar(64) null,
228 user_id varchar(64) null,
229 battery_level integer not null,
230 PRIMARY KEY(id)
231 ) TABLE_TYPE;
232
233 /*
234 ** Access point objects
235 */
236 CREATE TABLE access_points
237 (
238 id integer not null,
239 node_id integer not null,
240 mac_address varchar(12) null,
241 vendor varchar(64) null,
242 model varchar(128) null,
243 serial_number varchar(64) null,
244 ap_state integer not null,
245 ap_index integer not null,
246 PRIMARY KEY(id)
247 ) TABLE_TYPE;
248
249 /*
250 ** Rack objects
251 */
252 CREATE TABLE racks
253 (
254 id integer not null,
255 height integer not null,
256 top_bottom_num char(1) not null,
257 PRIMARY KEY(id)
258 ) TABLE_TYPE;
259
260 /*
261 ** Chassis objects
262 */
263 CREATE TABLE chassis
264 (
265 id integer not null,
266 controller_id integer not null,
267 flags integer not null,
268 rack_id integer not null,
269 rack_image varchar(36) null,
270 rack_position integer not null,
271 rack_height integer not null,
272 PRIMARY KEY(id)
273 ) TABLE_TYPE;
274
275 /*
276 ** Nodes information
277 */
278 CREATE TABLE nodes
279 (
280 id integer not null,
281 primary_name varchar(255) null,
282 primary_ip varchar(48) not null,
283 tunnel_id varchar(36) null,
284 node_flags integer not null,
285 runtime_flags integer not null,
286 snmp_version integer not null,
287 snmp_port integer not null,
288 community varchar(127) null,
289 usm_auth_password varchar(127) null,
290 usm_priv_password varchar(127) null,
291 usm_methods integer not null,
292 snmp_oid varchar(255) null,
293 auth_method integer not null,
294 secret varchar(64) null,
295 agent_port integer not null,
296 status_poll_type integer not null,
297 agent_version varchar(63) null,
298 platform_name varchar(63) null,
299 poller_node_id integer not null,
300 zone_guid integer not null,
301 proxy_node integer not null,
302 snmp_proxy integer not null,
303 icmp_proxy integer not null,
304 required_polls integer not null,
305 uname varchar(255) null,
306 use_ifxtable integer not null,
307 snmp_sys_name varchar(127) null,
308 snmp_sys_contact varchar(127) null,
309 snmp_sys_location varchar(127) null,
310 bridge_base_addr varchar(15) null,
311 lldp_id varchar(63) null,
312 down_since integer not null,
313 boot_time integer not null,
314 driver_name varchar(32) null,
315 rack_image varchar(36) null,
316 rack_position integer not null,
317 rack_height integer not null,
318 rack_id integer not null,
319 chassis_id integer not null,
320 agent_cache_mode char(1) not null,
321 last_agent_comm_time integer not null,
322 syslog_msg_count SQL_INT64 not null,
323 snmp_trap_count SQL_INT64 not null,
324 node_type integer not null,
325 node_subtype varchar(127) null,
326 ssh_login varchar(63) null,
327 ssh_password varchar(63) null,
328 ssh_proxy integer not null,
329 port_rows integer null,
330 port_numbering_scheme integer null,
331 agent_comp_mode char(1) not null, // compression mode for agent
332 PRIMARY KEY(id)
333 ) TABLE_TYPE;
334
335 /*
336 ** Clusters information
337 */
338
339 CREATE TABLE clusters
340 (
341 id integer not null,
342 cluster_type integer not null,
343 zone_guid integer not null,
344 PRIMARY KEY(id)
345 ) TABLE_TYPE;
346
347 /*
348 ** Cluster members
349 */
350
351 CREATE TABLE cluster_members
352 (
353 cluster_id integer not null,
354 node_id integer not null,
355 PRIMARY KEY(cluster_id,node_id)
356 ) TABLE_TYPE;
357
358 /*
359 ** Cluster interconnect subnets
360 */
361
362 CREATE TABLE cluster_sync_subnets
363 (
364 cluster_id integer not null,
365 subnet_addr varchar(48) not null,
366 subnet_mask integer not null,
367 PRIMARY KEY(cluster_id,subnet_addr)
368 ) TABLE_TYPE;
369
370 /*
371 ** Cluster resources
372 */
373
374 CREATE TABLE cluster_resources
375 (
376 cluster_id integer not null,
377 resource_id integer not null,
378 resource_name varchar(255),
379 ip_addr varchar(48) not null,
380 current_owner integer not null,
381 PRIMARY KEY(cluster_id,resource_id)
382 ) TABLE_TYPE;
383
384 /*
385 ** Subnets
386 */
387 CREATE TABLE subnets
388 (
389 id integer not null,
390 ip_addr varchar(48) not null,
391 ip_netmask integer not null,
392 zone_guid integer not null,
393 synthetic_mask integer not null,
394 PRIMARY KEY(id)
395 ) TABLE_TYPE;
396
397 /*
398 ** Nodes' interfaces
399 */
400 CREATE TABLE interfaces
401 (
402 id integer not null,
403 node_id integer not null,
404 flags integer not null,
405 if_type integer not null,
406 if_index integer not null,
407 mtu integer not null,
408 speed SQL_INT64 not null,
409 bridge_port integer not null,
410 phy_slot integer not null,
411 phy_port integer not null,
412 peer_node_id integer not null,
413 peer_if_id integer not null,
414 peer_proto integer not null,
415 mac_addr varchar(12) not null,
416 required_polls integer not null,
417 admin_state integer not null,
418 oper_state integer not null,
419 dot1x_pae_state integer not null,
420 dot1x_backend_state integer not null,
421 description varchar(255) null,
422 alias varchar(255) null,
423 iftable_suffix varchar(127) null,
424 PRIMARY KEY(id)
425 ) TABLE_TYPE;
426
427 /*
428 ** Interface IP addresses
429 */
430 CREATE TABLE interface_address_list
431 (
432 iface_id integer not null,
433 ip_addr varchar(48) not null,
434 ip_netmask integer not null,
435 PRIMARY KEY(iface_id,ip_addr)
436 ) TABLE_TYPE;
437
438 /*
439 ** Network services
440 */
441
442 CREATE TABLE network_services
443 (
444 id integer not null,
445 node_id integer not null,
446 service_type integer not null,
447 ip_bind_addr varchar(48) not null,
448 ip_proto integer not null,
449 ip_port integer not null,
450 check_request SQL_TEXT null,
451 check_responce SQL_TEXT null,
452 poller_node_id integer not null,
453 required_polls integer not null,
454 PRIMARY KEY(id)
455 ) TABLE_TYPE;
456
457 /*
458 ** VPN connectors
459 */
460 CREATE TABLE vpn_connectors
461 (
462 id integer not null,
463 node_id integer not null,
464 peer_gateway integer not null,
465 PRIMARY KEY(id)
466 ) TABLE_TYPE;
467
468 /*
469 ** VPN connector networks
470 */
471 CREATE TABLE vpn_connector_networks
472 (
473 vpn_id integer not null,
474 network_type integer not null, // 0 == local, 1 == remote
475 ip_addr varchar(48) not null,
476 ip_netmask integer not null,
477 PRIMARY KEY(vpn_id,ip_addr)
478 ) TABLE_TYPE;
479
480 /*
481 ** Container objects
482 */
483 CREATE TABLE object_containers
484 (
485 id integer not null,
486 object_class integer not null,
487 flags integer not null,
488 auto_bind_filter SQL_TEXT null,
489 PRIMARY KEY(id)
490 ) TABLE_TYPE;
491
492 /*
493 ** Condition objects
494 */
495 CREATE TABLE conditions
496 (
497 id integer not null,
498 activation_event integer not null,
499 deactivation_event integer not null,
500 source_object integer not null,
501 active_status integer not null,
502 inactive_status integer not null,
503 script SQL_TEXT not null,
504 PRIMARY KEY(id)
505 ) TABLE_TYPE;
506
507 /*
508 ** DCI to condition mapping
509 */
510 CREATE TABLE cond_dci_map
511 (
512 condition_id integer not null,
513 sequence_number integer not null,
514 dci_id integer not null,
515 node_id integer not null,
516 dci_func integer not null,
517 num_polls integer not null,
518 PRIMARY KEY(condition_id,sequence_number)
519 ) TABLE_TYPE;
520
521 /**
522 * Data collection templates
523 */
524 CREATE TABLE templates
525 (
526 id integer not null,
527 version integer not null,
528 flags integer not null,
529 apply_filter SQL_TEXT null,
530 PRIMARY KEY(id)
531 ) TABLE_TYPE;
532
533 /**
534 * Mapping hosts to templates
535 */
536 CREATE TABLE dct_node_map
537 (
538 template_id integer not null,
539 node_id integer not null,
540 PRIMARY KEY(template_id,node_id)
541 ) TABLE_TYPE;
542
543 /**
544 * Nodes to subnets mapping
545 */
546 CREATE TABLE nsmap
547 (
548 subnet_id integer not null,
549 node_id integer not null,
550 PRIMARY KEY(subnet_id,node_id)
551 ) TABLE_TYPE;
552
553 /**
554 * Container members
555 */
556 CREATE TABLE container_members
557 (
558 container_id integer not null,
559 object_id integer not null,
560 PRIMARY KEY(container_id,object_id)
561 ) TABLE_TYPE;
562
563 /**
564 * Objects' ACLs
565 */
566 CREATE TABLE acl
567 (
568 object_id integer not null,
569 user_id integer not null,
570 access_rights integer not null,
571 PRIMARY KEY(object_id,user_id)
572 ) TABLE_TYPE;
573
574 /**
575 * Trusted nodes - used for cross-node data collection
576 * Source object is an object providing data (it can be node or condition),
577 * and target node is a node owning DCI
578 */
579 CREATE TABLE trusted_nodes
580 (
581 source_object_id integer not null,
582 target_node_id integer not null,
583 PRIMARY KEY(source_object_id,target_node_id)
584 ) TABLE_TYPE;
585
586 /**
587 * Data collection items
588 *
589 * If node_id != 0, it's an item bound to node, and template_id points to
590 * the template used for creating this item. In this case, template_id = 0
591 * means that item was created manually.
592 * If node_id = 0, it's a template item, and template_id points to a template
593 * this item belongs to.
594 * If both node_id and template_id is 0, it's an error.
595 */
596 CREATE TABLE items
597 (
598 item_id integer not null,
599 node_id integer not null,
600 template_id integer not null,
601 template_item_id integer not null,
602 guid varchar(36) not null,
603 name varchar(1023) null,
604 description varchar(255) null,
605 flags integer not null,
606 source integer not null, // 0 for internal or 1 for native agent or 2 for SNMP
607 snmp_port integer not null,
608 datatype integer not null,
609 polling_interval integer not null,
610 retention_time integer not null,
611 status integer not null, // ACTIVE, DISABLED or NOT_SUPPORTED
612 snmp_raw_value_type integer not null,
613 delta_calculation integer not null,
614 transformation SQL_TEXT, // Transformation script
615 instance varchar(255) null, // Free form text which can be used in events
616 system_tag varchar(255) null, // System tag
617 resource_id integer not null, // associated cluster resource ID
618 proxy_node integer not null, // ID of proxy node (for SNMP and agent items)
619 base_units integer not null, // bytes, seconds, etc.
620 unit_multiplier integer not null, // kilo, mega, milli, etc.
621 custom_units_name varchar(63) null, // units name of base_units = CUSTOM
622 perftab_settings SQL_TEXT null, // Settings for displaying graph on performance tab
623 instd_method integer not null,
624 instd_data varchar(255) null,
625 instd_filter SQL_TEXT null,
626 samples integer not null,
627 npe_name varchar(15) null,
628 comments SQL_TEXT null,
629 PRIMARY KEY(item_id)
630 ) TABLE_TYPE;
631
632 CREATE INDEX idx_items_node_id ON items(node_id);
633
634 /*
635 ** Data collection tables
636 */
637 CREATE TABLE dc_tables
638 (
639 item_id integer not null,
640 node_id integer not null,
641 template_id integer not null,
642 template_item_id integer not null,
643 guid varchar(36) not null,
644 name varchar(1023) null,
645 description varchar(255) null,
646 flags integer not null,
647 source integer not null, // 0 for internal or 1 for native agent or 2 for SNMP
648 snmp_port integer not null,
649 polling_interval integer not null,
650 retention_time integer not null,
651 status integer not null, // ACTIVE, DISABLED or NOT_SUPPORTED
652 system_tag varchar(255) null, // System tag
653 resource_id integer not null, // associated cluster resource ID
654 proxy_node integer not null, // ID of proxy node (for SNMP and agent items)
655 perftab_settings SQL_TEXT null, // Settings for displaying graph on performance tab
656 transformation_script SQL_TEXT null,
657 comments SQL_TEXT null,
658 instance varchar(255) null,
659 instd_method integer not null,
660 instd_data varchar(255) null,
661 instd_filter SQL_TEXT null,
662 PRIMARY KEY(item_id)
663 ) TABLE_TYPE;
664
665 CREATE INDEX idx_dc_tables_node_id ON dc_tables(node_id);
666
667 /*
668 ** Columns for data collection tables
669 */
670 CREATE TABLE dc_table_columns
671 (
672 table_id integer not null,
673 sequence_number integer not null,
674 column_name varchar(63) not null,
675 snmp_oid varchar(1023) null, // SNMP OID for this column, valid only for SNMP tables
676 flags integer not null,
677 display_name varchar(255) null,
678 PRIMARY KEY(table_id,column_name)
679 ) TABLE_TYPE;
680
681 /*
682 ** Column name dictionary
683 */
684 CREATE TABLE dct_column_names
685 (
686 column_id integer not null,
687 column_name varchar(63) not null,
688 PRIMARY KEY(column_id)
689 ) TABLE_TYPE;
690
691 /*
692 ** Table thresholds
693 */
694 CREATE TABLE dct_thresholds
695 (
696 id integer not null,
697 table_id integer not null,
698 sequence_number integer not null,
699 activation_event integer not null,
700 deactivation_event integer not null,
701 sample_count integer not null,
702 PRIMARY KEY(id)
703 ) TABLE_TYPE;
704
705 /*
706 ** Table threshold conditions
707 */
708 CREATE TABLE dct_threshold_conditions
709 (
710 threshold_id integer not null,
711 group_id integer not null,
712 sequence_number integer not null,
713 column_name varchar(63) null,
714 check_operation integer not null,
715 check_value varchar(255) null,
716 PRIMARY KEY(threshold_id,group_id,sequence_number)
717 ) TABLE_TYPE;
718
719 /*
720 ** Table threshold instances
721 */
722 CREATE TABLE dct_threshold_instances
723 (
724 threshold_id integer not null,
725 instance varchar(255) not null,
726 match_count integer not null,
727 is_active char(1) not null,
728 PRIMARY KEY(threshold_id,instance)
729 ) TABLE_TYPE;
730
731 /*
732 ** Schedules for DCIs
733 */
734 CREATE TABLE dci_schedules
735 (
736 schedule_id integer not null,
737 item_id integer not null,
738 schedule varchar(255) null,
739 PRIMARY KEY(item_id,schedule_id)
740 ) TABLE_TYPE;
741
742 /*
743 ** Latest raw values for all data collection items
744 */
745 CREATE TABLE raw_dci_values
746 (
747 item_id integer not null,
748 raw_value varchar(255) null,
749 transformed_value varchar(255) null,
750 last_poll_time integer not null,
751 PRIMARY KEY(item_id)
752 ) TABLE_TYPE;
753
754 #if !defined(DB_ORACLE) && !defined(DB_DB2) && !defined(DB_POSTGRESQL)
755 CREATE INDEX idx_raw_dci_values_item_id ON raw_dci_values(item_id);
756 #endif
757
758 /*
759 ** Events configuration
760 */
761 CREATE TABLE event_cfg
762 (
763 event_code integer not null,
764 event_name varchar(63) not null, // Short event name
765 guid varchar(36) not null,
766 severity integer not null,
767 flags integer not null,
768 message varchar(2000) null, /* Message template */
769 description SQL_TEXT null,
770 PRIMARY KEY(event_code)
771 ) TABLE_TYPE;
772
773 /*
774 ** Event log
775 */
776 CREATE TABLE event_log
777 (
778 event_id SQL_INT64 not null,
779 event_code integer not null,
780 event_timestamp integer not null,
781 event_source integer not null, /* Source object ID */
782 dci_id integer not null, /* ID of related DCI or 0 */
783 event_severity integer not null,
784 event_message varchar(2000) null,
785 root_event_id SQL_INT64 not null, /* Non-zero if current event correlates to some other event */
786 user_tag varchar(63) null,
787 PRIMARY KEY(event_id)
788 ) TABLE_TYPE;
789
790 CREATE INDEX idx_event_log_event_timestamp ON event_log(event_timestamp);
791
792 CREATE INDEX idx_event_log_source ON event_log(event_source);
793
794 #if defined(DB_POSTGRESQL)
795 CREATE INDEX idx_event_log_root_id ON event_log(root_event_id) WHERE root_event_id > 0;
796 #elif defined(DB_ORACLE)
797 CREATE OR REPLACE FUNCTION zero_to_null(id NUMBER)
798 RETURN NUMBER
799 DETERMINISTIC
800 AS BEGIN
801 IF id > 0 THEN
802 RETURN id;
803 ELSE
804 RETURN NULL;
805 END IF;
806 END;
807 /
808 CREATE INDEX idx_event_log_root_id ON event_log(zero_to_null(root_event_id));
809 #else
810 CREATE INDEX idx_event_log_root_id ON event_log(root_event_id);
811 #endif
812
813 /*
814 ** Actions on events
815 */
816 CREATE TABLE actions
817 (
818 action_id integer not null,
819 action_name varchar(63) not null,
820 action_type integer not null,
821 is_disabled integer not null,
822 // Field "rcpt_addr" holds e-mail address for e-mail actions,
823 // phone number for sms actions, and remote host address for
824 // remote execution actions
825 rcpt_addr varchar(255) null,
826 email_subject varchar(255) null,
827 // Field "action_data" holds message text for e-mail and sms actions,
828 // command line for external command execution actions, or
829 // action name with optional arguments for remote execution actions
830 action_data SQL_TEXT null,
831 PRIMARY KEY(action_id)
832 ) TABLE_TYPE;
833
834 /*
835 ** Event groups
836 */
837 CREATE TABLE event_groups
838 (
839 id integer not null,
840 name varchar(63) not null,
841 description varchar(255) not null,
842 range_start integer not null,
843 range_end integer not null,
844 PRIMARY KEY(id)
845 ) TABLE_TYPE;
846
847 /*
848 ** Event group members
849 */
850 CREATE TABLE event_group_members
851 (
852 group_id integer not null,
853 event_code integer not null,
854 PRIMARY KEY(group_id,event_code)
855 ) TABLE_TYPE;
856
857 /*
858 ** Event processing policy
859 */
860 CREATE TABLE event_policy
861 (
862 rule_id integer not null, // Rule number
863 rule_guid varchar(36) not null,
864 flags integer not null,
865 comments SQL_TEXT null,
866 script SQL_TEXT null,
867 alarm_message varchar(2000) null,
868 alarm_severity integer not null,
869 alarm_key varchar(255) null, // Alarm key (used for auto termination)
870 alarm_timeout integer not null, // Timeout before sending event
871 alarm_timeout_event integer not null, // Event to be sent on timeout
872 PRIMARY KEY(rule_id)
873 ) TABLE_TYPE;
874
875 /**
876 *
877 */
878 CREATE TABLE policy_source_list
879 (
880 rule_id integer not null,
881 object_id integer not null,
882 PRIMARY KEY(rule_id,object_id)
883 ) TABLE_TYPE;
884
885 /**
886 *
887 */
888 CREATE TABLE policy_event_list
889 (
890 rule_id integer not null,
891 event_code integer not null,
892 PRIMARY KEY(rule_id,event_code)
893 ) TABLE_TYPE;
894
895 /**
896 *
897 */
898 CREATE TABLE policy_action_list
899 (
900 rule_id integer not null,
901 action_id integer not null,
902 PRIMARY KEY(rule_id,action_id)
903 ) TABLE_TYPE;
904
905 /**
906 *
907 */
908 CREATE TABLE policy_pstorage_actions
909 (
910 rule_id integer not null,
911 ps_key varchar(255) not null,
912 value varchar(2000) null,
913 action integer not null,
914 PRIMARY KEY(rule_id,ps_key,action)
915 ) TABLE_TYPE;
916
917 /*
918 ** Threshold checking rules
919 */
920 CREATE TABLE thresholds
921 (
922 threshold_id integer not null,
923 item_id integer not null,
924 sequence_number integer not null,
925 fire_value varchar(255) null,
926 rearm_value varchar(255) null,
927 check_function integer not null,
928 check_operation integer not null,
929 sample_count integer not null,
930 script SQL_TEXT null,
931 event_code integer not null,
932 rearm_event_code integer not null,
933 repeat_interval integer not null,
934 current_state integer not null,
935 current_severity integer not null,
936 match_count integer not null,
937 last_event_timestamp integer not null,
938 PRIMARY KEY(threshold_id)
939 ) TABLE_TYPE;
940
941 CREATE INDEX idx_thresholds_item_id ON thresholds(item_id);
942 CREATE INDEX idx_thresholds_sequence ON thresholds(sequence_number);
943
944 /*
945 ** Alarms
946 */
947 CREATE TABLE alarms
948 (
949 alarm_id integer not null, // Unique alarm identifier
950 alarm_state integer not null,
951 hd_state integer not null, // Help desk system state
952 hd_ref varchar(63) null, // Help desk reference
953 creation_time integer not null,
954 last_change_time integer not null,
955 source_object_id integer not null,
956 source_event_code integer not null,
957 source_event_id SQL_INT64 not null,
958 dci_id integer not null,
959 message varchar(2000) null,
960 original_severity integer not null,
961 current_severity integer not null,
962 repeat_count integer not null,
963 alarm_key varchar(255) null, // Alarm key (used for auto acknowlegment)
964 ack_by integer not null, // ID of user who was acknowleged alarm
965 resolved_by integer not null, // ID of user who was resolved alarm
966 term_by integer not null, // ID of user who was terminated alarm
967 timeout integer not null,
968 timeout_event integer not null,
969 ack_timeout integer not null,
970 alarm_category_ids varchar(255) null,
971 PRIMARY KEY(alarm_id)
972 ) TABLE_TYPE;
973
974 /*
975 ** Alarm notes
976 */
977 CREATE TABLE alarm_notes
978 (
979 note_id integer not null,
980 alarm_id integer not null,
981 change_time integer not null,
982 user_id integer not null, // Last edited by
983 note_text SQL_TEXT null,
984 PRIMARY KEY(note_id)
985 ) TABLE_TYPE;
986
987 CREATE INDEX idx_alarm_notes_alarm_id ON alarm_notes(alarm_id);
988
989 /*
990 ** Source events for alarms
991 */
992 CREATE TABLE alarm_events
993 (
994 alarm_id integer not null,
995 event_id SQL_INT64 not null,
996 event_code integer not null,
997 event_name varchar(63) null,
998 severity integer not null,
999 source_object_id integer not null,
1000 event_timestamp integer not null,
1001 message varchar(2000) null,
1002 PRIMARY KEY(alarm_id,event_id)
1003 ) TABLE_TYPE;
1004
1005 CREATE INDEX idx_alarm_events_alarm_id ON alarm_events(alarm_id);
1006
1007 /*
1008 ** Alarm categories
1009 */
1010 CREATE TABLE alarm_categories
1011 (
1012 id integer not null,
1013 name varchar(63) null,
1014 descr varchar(255) null,
1015 PRIMARY KEY(id)
1016 ) TABLE_TYPE;
1017
1018 /*
1019 ** Alarm category access control list
1020 */
1021 CREATE TABLE alarm_category_acl
1022 (
1023 category_id integer not null,
1024 user_id integer not null,
1025 PRIMARY KEY(category_id,user_id)
1026 ) TABLE_TYPE;
1027
1028 /*
1029 ** Alarm-category map
1030 */
1031 CREATE TABLE alarm_category_map
1032 (
1033 alarm_id integer not null,
1034 category_id integer not null,
1035 PRIMARY KEY(alarm_id,category_id)
1036 ) TABLE_TYPE;
1037
1038 /*
1039 ** SNMP trap configuration
1040 */
1041
1042 CREATE TABLE snmp_trap_cfg
1043 (
1044 guid varchar(36) not null,
1045 trap_id integer not null,
1046 snmp_oid varchar(255),
1047 event_code integer not null,
1048 user_tag varchar(63),
1049 description varchar(255),
1050 PRIMARY KEY(trap_id)
1051 ) TABLE_TYPE;
1052
1053 /*
1054 ** SNMP trap parameters mapping
1055 */
1056 CREATE TABLE snmp_trap_pmap
1057 (
1058 trap_id integer not null,
1059 parameter integer not null,
1060 flags integer not null,
1061 snmp_oid varchar(255) null,
1062 description varchar(255) null,
1063 PRIMARY KEY(trap_id,parameter)
1064 ) TABLE_TYPE;
1065
1066 /*
1067 ** Agent packages
1068 */
1069 CREATE TABLE agent_pkg
1070 (
1071 pkg_id integer not null,
1072 pkg_name varchar(63),
1073 version varchar(31),
1074 platform varchar(63),
1075 pkg_file varchar(255),
1076 description varchar(255),
1077 PRIMARY KEY(pkg_id)
1078 ) TABLE_TYPE;
1079
1080 /*
1081 ** Object tools
1082 */
1083 CREATE TABLE object_tools
1084 (
1085 tool_id integer not null,
1086 guid varchar(36) not null,
1087 tool_name varchar(255) null,
1088 tool_type integer not null,
1089 tool_data SQL_TEXT null,
1090 description varchar(255) null,
1091 flags integer not null,
1092 tool_filter SQL_TEXT null,
1093 confirmation_text varchar(255) null,
1094 command_name varchar(255) null,
1095 command_short_name varchar(31) null,
1096 icon SQL_TEXT null,
1097 PRIMARY KEY(tool_id)
1098 ) TABLE_TYPE;
1099
1100 /*
1101 ** Access list for object tools
1102 */
1103 CREATE TABLE object_tools_acl
1104 (
1105 tool_id integer not null,
1106 user_id integer not null,
1107 PRIMARY KEY(tool_id,user_id)
1108 ) TABLE_TYPE;
1109
1110 /*
1111 ** Configuration of columns for SNMP_TABLE and AGENT_TABLE type of object tools
1112 */
1113 CREATE TABLE object_tools_table_columns
1114 (
1115 tool_id integer not null,
1116 col_number integer not null,
1117 col_name varchar(255) null,
1118 col_oid varchar(255) null,
1119 col_format integer, // Column format (integer, string, etc.)
1120 col_substr integer, // Number of matching substring in regexp
1121 PRIMARY KEY(tool_id,col_number)
1122 ) TABLE_TYPE;
1123
1124 /**
1125 * Input fields for object tools
1126 */
1127 CREATE TABLE object_tools_input_fields
1128 (
1129 tool_id integer not null,
1130 name varchar(31) not null,
1131 input_type char(1) not null,
1132 display_name varchar(127) null,
1133 sequence_num integer not null,
1134 config SQL_TEXT null,
1135 PRIMARY KEY(tool_id,name)
1136 ) TABLE_TYPE;
1137
1138 /*
1139 ** Stored syslog messages
1140 */
1141 CREATE TABLE syslog
1142 (
1143 msg_id SQL_INT64 not null,
1144 msg_timestamp integer not null,
1145 facility integer not null,
1146 severity integer not null,
1147 source_object_id integer not null,
1148 hostname varchar(127) null,
1149 msg_tag varchar(32) null,
1150 msg_text SQL_TEXT null,
1151 PRIMARY KEY(msg_id)
1152 ) TABLE_TYPE;
1153
1154 CREATE INDEX idx_syslog_msg_timestamp ON syslog(msg_timestamp);
1155 CREATE INDEX idx_syslog_source ON syslog(source_object_id);
1156
1157 /*
1158 ** Script library
1159 */
1160 CREATE TABLE script_library
1161 (
1162 guid varchar(36) not null,
1163 script_id integer not null,
1164 script_name varchar(255) not null,
1165 script_code SQL_TEXT null,
1166 PRIMARY KEY(script_id)
1167 ) TABLE_TYPE;
1168
1169 /*
1170 ** Extended SNMP trap log
1171 */
1172
1173 CREATE TABLE snmp_trap_log
1174 (
1175 trap_id SQL_INT64 not null,
1176 trap_timestamp integer not null,
1177 ip_addr varchar(48) not null,
1178 object_id integer not null,
1179 trap_oid varchar(255) not null,
1180 trap_varlist SQL_TEXT null,
1181 PRIMARY KEY(trap_id)
1182 ) TABLE_TYPE;
1183
1184 CREATE INDEX idx_snmp_trap_log_tt ON snmp_trap_log(trap_timestamp);
1185 CREATE INDEX idx_snmp_trap_log_oid ON snmp_trap_log(object_id);
1186
1187 /*
1188 ** Agent configurations
1189 */
1190 CREATE TABLE agent_configs
1191 (
1192 config_id integer not null,
1193 config_name varchar(255) not null,
1194 config_file SQL_TEXT not null,
1195 config_filter SQL_TEXT not null,
1196 sequence_number integer not null,
1197 PRIMARY KEY(config_id)
1198 ) TABLE_TYPE;
1199
1200 /*
1201 ** Address lists
1202 */
1203 CREATE TABLE address_lists
1204 (
1205 list_type integer not null, // discovery filter, etc.
1206 community_id integer not null, // community id for snmp community addr list, otherwise 0
1207 addr_type integer not null, // 0 - addr/mask, 1 - address range
1208 addr1 varchar(48) not null,
1209 addr2 varchar(48) not null,
1210 PRIMARY KEY(list_type,community_id,addr_type,addr1,addr2)
1211 ) TABLE_TYPE;
1212
1213 CREATE INDEX idx_address_lists_list_type ON address_lists(list_type);
1214
1215 /*
1216 ** Graphs
1217 */
1218 CREATE TABLE graphs
1219 (
1220 graph_id integer not null,
1221 owner_id integer not null,
1222 flags integer not null,
1223 name varchar(255) not null,
1224 config SQL_TEXT null,
1225 filters SQL_TEXT null,
1226 PRIMARY KEY(graph_id)
1227 ) TABLE_TYPE;
1228
1229 /*
1230 ** Graph access lists
1231 */
1232 CREATE TABLE graph_acl
1233 (
1234 graph_id integer not null,
1235 user_id integer not null,
1236 user_rights integer not null,
1237 PRIMARY KEY(graph_id,user_id)
1238 ) TABLE_TYPE;
1239
1240 /*
1241 ** Certificates
1242 */
1243
1244 CREATE TABLE certificates
1245 (
1246 cert_id integer not null,
1247 cert_type integer not null,
1248 cert_data SQL_TEXT not null, // Certificate in PEM format
1249 subject SQL_TEXT not null,
1250 comments SQL_TEXT not null,
1251 PRIMARY KEY(cert_id)
1252 ) TABLE_TYPE;
1253
1254 /*
1255 ** Audit log
1256 */
1257 CREATE TABLE audit_log
1258 (
1259 record_id integer not null,
1260 timestamp integer not null,
1261 subsystem varchar(32) not null,
1262 success integer not null,
1263 user_id integer not null, // 0x7FFFFFFF for system
1264 workstation varchar(63) not null,
1265 session_id integer not null,
1266 object_id integer not null,
1267 message SQL_TEXT null,
1268 old_value SQL_TEXT null,
1269 new_value SQL_TEXT null,
1270 value_diff SQL_TEXT null,
1271 PRIMARY KEY(record_id)
1272 ) TABLE_TYPE;
1273
1274 /*
1275 ** Persistent storage
1276 */
1277 CREATE TABLE persistent_storage
1278 (
1279 entry_key varchar(255) not null,
1280 value varchar(2000) null,
1281 PRIMARY KEY(entry_key)
1282 ) TABLE_TYPE;
1283
1284 /*
1285 ** List of possible community strings
1286 */
1287 CREATE TABLE snmp_communities
1288 (
1289 id integer not null,
1290 community varchar(255) null,
1291 PRIMARY KEY(id)
1292 ) TABLE_TYPE;
1293
1294 /*
1295 ** Agent policies - common attributes
1296 */
1297 CREATE TABLE ap_common
1298 (
1299 id integer not null,
1300 policy_type integer not null,
1301 version integer not null,
1302 PRIMARY KEY(id)
1303 ) TABLE_TYPE;
1304
1305 /*
1306 ** Agent policies - node binding
1307 */
1308 CREATE TABLE ap_bindings
1309 (
1310 policy_id integer not null,
1311 node_id integer not null,
1312 PRIMARY KEY(policy_id,node_id)
1313 ) TABLE_TYPE;
1314
1315 /*
1316 ** Agent policies - configuration files
1317 */
1318 CREATE TABLE ap_config_files
1319 (
1320 policy_id integer not null,
1321 file_content SQL_TEXT null,
1322 PRIMARY KEY(policy_id)
1323 ) TABLE_TYPE;
1324
1325 /**
1326 ** Agent policies - log parser files
1327 */
1328 CREATE TABLE ap_log_parser
1329 (
1330 policy_id integer not null,
1331 file_content SQL_TEXT null,
1332 PRIMARY KEY(policy_id)
1333 ) TABLE_TYPE;
1334
1335 /*
1336 ** Default SNMP v3 USM credentials
1337 */
1338 CREATE TABLE usm_credentials
1339 (
1340 id integer not null,
1341 user_name varchar(255) not null,
1342 auth_method integer not null,
1343 priv_method integer not null,
1344 auth_password varchar(255),
1345 priv_password varchar(255),
1346 PRIMARY KEY(id)
1347 ) TABLE_TYPE;
1348
1349 /*
1350 ** Network maps
1351 */
1352 CREATE TABLE network_maps
1353 (
1354 id integer not null,
1355 map_type integer not null,
1356 layout integer not null,
1357 radius integer not null,
1358 background varchar(36) null,
1359 bg_latitude varchar(20) null,
1360 bg_longitude varchar(20) null,
1361 bg_zoom integer null,
1362 flags integer not null,
1363 bg_color integer not null,
1364 link_color integer not null,
1365 link_routing integer not null,
1366 object_display_mode integer not null,
1367 filter SQL_TEXT null,
1368 PRIMARY KEY(id)
1369 ) TABLE_TYPE;
1370
1371 /**
1372 * Elements of network maps
1373 */
1374 CREATE TABLE network_map_elements
1375 (
1376 map_id integer not null,
1377 element_id integer not null,
1378 element_type integer not null,
1379 element_data SQL_TEXT not null,
1380 flags integer not null,
1381 PRIMARY KEY(map_id,element_id)
1382 ) TABLE_TYPE;
1383
1384 /**
1385 * Links on network maps
1386 */
1387 CREATE TABLE network_map_links
1388 (
1389 map_id integer not null,
1390 element1 integer not null,
1391 element2 integer not null,
1392 link_type integer not null,
1393 link_name varchar(255) null,
1394 connector_name1 varchar(255) null,
1395 connector_name2 varchar(255) null,
1396 element_data SQL_TEXT null,
1397 flags integer not null
1398 ) TABLE_TYPE;
1399
1400 CREATE INDEX idx_network_map_links_map_id ON network_map_links(map_id);
1401
1402 /**
1403 * Seed nodes of network maps
1404 */
1405 CREATE TABLE network_map_seed_nodes
1406 (
1407 map_id integer not null,
1408 seed_node_id integer not null,
1409 PRIMARY KEY(map_id,seed_node_id)
1410 ) TABLE_TYPE;
1411
1412 /**
1413 * Image Library
1414 */
1415 CREATE TABLE images
1416 (
1417 guid varchar(36) not null,
1418 name varchar(63) not null,
1419 category varchar(63) not null,
1420 mimetype varchar(32) not null,
1421 protected integer default 0,
1422 PRIMARY KEY(guid),
1423 UNIQUE(name, category)
1424 ) TABLE_TYPE;
1425
1426 /**
1427 * Dashboards
1428 */
1429 CREATE TABLE dashboards
1430 (
1431 id integer not null,
1432 num_columns integer not null,
1433 options integer not null,
1434 PRIMARY KEY(id)
1435 ) TABLE_TYPE;
1436
1437 /**
1438 * Dashboard elements
1439 */
1440 CREATE TABLE dashboard_elements
1441 (
1442 dashboard_id integer not null,
1443 element_id integer not null,
1444 element_type integer not null,
1445 element_data SQL_TEXT null,
1446 layout_data SQL_TEXT null,
1447 PRIMARY KEY(dashboard_id,element_id)
1448 ) TABLE_TYPE;
1449
1450 /**
1451 * Associations between dashboards and other objects
1452 */
1453 CREATE TABLE dashboard_associations
1454 (
1455 object_id integer not null,
1456 dashboard_id integer not null,
1457 PRIMARY KEY(object_id,dashboard_id)
1458 ) TABLE_TYPE;
1459
1460 /**
1461 * SLA business services
1462 */
1463 CREATE TABLE business_services
1464 (
1465 service_id integer not null,
1466 PRIMARY KEY(service_id)
1467 ) TABLE_TYPE;
1468
1469 /**
1470 * SLA service checks
1471 */
1472 CREATE TABLE slm_checks
1473 (
1474 id integer not null,
1475 type integer not null, // 1 - threshold, 2 - script
1476 content SQL_TEXT null, // if type == 2
1477 threshold_id integer not null, // if type == 1; refers to thresholds.id
1478 reason varchar(255) null,
1479 is_template integer not null,
1480 template_id integer not null, // template check ID
1481 current_ticket integer not null,
1482 PRIMARY KEY(id)
1483 ) TABLE_TYPE;
1484
1485 /*
1486 ** SLA node links
1487 */
1488 CREATE TABLE node_links
1489 (
1490 nodelink_id integer not null,
1491 node_id integer not null, // refers to node.id
1492 PRIMARY KEY(nodelink_id)
1493 ) TABLE_TYPE;
1494
1495 /*
1496 ** SLA - agreements
1497 */
1498 CREATE TABLE slm_agreements
1499 (
1500 agreement_id integer not null,
1501 service_id integer not null,
1502 org_id integer not null,
1503 uptime varchar(63) not null, // required uptime, numeric(10,2) ?
1504 period integer not null, // 1 - day, 2 - month
1505 start_date integer not null, // date in YYYYMMDD format
1506 notes varchar(255),
1507 PRIMARY KEY(agreement_id)
1508 ) TABLE_TYPE;
1509
1510 /*
1511 ** SLA tickets
1512 */
1513
1514 CREATE TABLE slm_tickets
1515 (
1516 ticket_id integer not null,
1517 service_id integer not null,
1518 check_id integer not null,
1519 create_timestamp integer not null,
1520 close_timestamp integer not null,
1521 reason varchar(255) null,
1522 PRIMARY KEY(ticket_id)
1523 ) TABLE_TYPE;
1524
1525 /*
1526 ** SLA service change log
1527 */
1528
1529 CREATE TABLE slm_service_history
1530 (
1531 record_id integer not null,
1532 service_id integer not null,
1533 change_timestamp integer not null,
1534 new_status integer not null,
1535 PRIMARY KEY(record_id)
1536 ) TABLE_TYPE;
1537
1538 /*
1539 ** Organizations
1540 */
1541
1542 CREATE TABLE organizations
1543 (
1544 id integer not null,
1545 parent_id integer not null,
1546 org_type integer not null,
1547 name varchar(63) not null,
1548 description varchar(255),
1549 manager integer not null, // manager - id from "persons" table
1550 PRIMARY KEY(id)
1551 ) TABLE_TYPE;
1552
1553 /*
1554 ** Persons
1555 */
1556
1557 CREATE TABLE persons
1558 (
1559 id integer not null,
1560 org_id integer not null,
1561 first_name varchar(63),
1562 last_name varchar(63),
1563 title varchar(255),
1564 status integer not null,
1565 PRIMARY KEY(id)
1566 ) TABLE_TYPE;
1567
1568 /*
1569 ** Job history
1570 */
1571 CREATE TABLE job_history
1572 (
1573 id integer not null,
1574 time_created integer not null,
1575 time_started integer not null,
1576 time_finished integer not null,
1577 job_type varchar(127) null,
1578 description varchar(255) null,
1579 additional_info varchar(255) null,
1580 node_id integer not null,
1581 user_id integer not null,
1582 status integer not null,
1583 failure_message varchar(255) null,
1584 PRIMARY KEY(id)
1585 ) TABLE_TYPE;
1586
1587 /*
1588 ** License repository
1589 */
1590 CREATE TABLE licenses
1591 (
1592 id integer not null,
1593 content SQL_TEXT null,
1594 PRIMARY KEY(id)
1595 ) TABLE_TYPE;
1596
1597 /*
1598 ** Mapping tables
1599 */
1600 CREATE TABLE mapping_tables
1601 (
1602 id integer not null,
1603 name varchar(63) not null,
1604 flags integer not null,
1605 description SQL_TEXT4K null,
1606 PRIMARY KEY(id)
1607 ) TABLE_TYPE;
1608
1609 /*
1610 ** Mapping tables content
1611 */
1612 CREATE TABLE mapping_data
1613 (
1614 table_id integer not null,
1615 md_key varchar(63) not null,
1616 md_value varchar(255) null,
1617 description SQL_TEXT4K null,
1618 PRIMARY KEY(table_id,md_key)
1619 ) TABLE_TYPE;
1620
1621 /*
1622 ** DCI summary tables
1623 */
1624 CREATE TABLE dci_summary_tables
1625 (
1626 id integer not null,
1627 guid varchar(36) not null,
1628 menu_path varchar(255) null,
1629 title varchar(127) null,
1630 node_filter SQL_TEXT null,
1631 flags integer not null,
1632 columns SQL_TEXT null,
1633 PRIMARY KEY(id)
1634 ) TABLE_TYPE;
1635
1636 /*
1637 ** Scheduled tasks
1638 */
1639 CREATE TABLE scheduled_tasks
1640 (
1641 id integer not null,
1642 taskId varchar(255) null,
1643 schedule varchar(127) null,
1644 params varchar(1023) null,
1645 execution_time integer not null,
1646 last_execution_time integer not null,
1647 flags integer not null,
1648 owner integer not null,
1649 object_id integer not null,
1650 comments varchar(255) null,
1651 PRIMARY KEY(id)
1652 ) TABLE_TYPE;
1653
1654 /*
1655 ** ZMQ Subscriptions
1656 */
1657 CREATE TABLE zmq_subscription
1658 (
1659 object_id integer not null,
1660 subscription_type char(1) not null,
1661 ignore_items integer not null,
1662 items SQL_TEXT,
1663 PRIMARY KEY(object_id, subscription_type)
1664 ) TABLE_TYPE;
1665
1666 /**
1667 * Currency codes
1668 */
1669 CREATE TABLE currency_codes
1670 (
1671 numeric_code char(3) not null,
1672 alpha_code char(3) not null,
1673 description varchar(127) not null,
1674 exponent integer not null,
1675 PRIMARY KEY(numeric_code)
1676 ) TABLE_TYPE;
1677
1678 /**
1679 * Country codes
1680 */
1681 CREATE TABLE country_codes
1682 (
1683 numeric_code char(3) not null,
1684 alpha_code char(2) not null,
1685 alpha3_code char(3) not null,
1686 name varchar(127) not null,
1687 PRIMARY KEY(numeric_code)
1688 ) TABLE_TYPE;
1689
1690 /**
1691 * Config repositories
1692 */
1693 CREATE TABLE config_repositories
1694 (
1695 id integer not null,
1696 url varchar(1023) not null,
1697 auth_token varchar(63) null,
1698 description varchar(1023) null,
1699 PRIMARY KEY(id)
1700 ) TABLE_TYPE;
1701
1702 /**
1703 * Network equipment port layouts
1704 */
1705 CREATE TABLE port_layouts
1706 (
1707 device_oid varchar(255) not null,
1708 numbering_scheme char(1) not null,
1709 row_count char(1) not null,
1710 layout_data varchar(4000) null,
1711 PRIMARY KEY(device_oid)
1712 ) TABLE_TYPE;
1713
1714 /**
1715 * Snapshot for object access rights
1716 */
1717 CREATE TABLE object_access_snapshot
1718 (
1719 user_id integer not null,
1720 object_id integer not null,
1721 access_rights integer not null,
1722 PRIMARY KEY(user_id,object_id)
1723 ) TABLE_TYPE;