CREATE INDEX "name" on "access_points" ("name", "radio_number");
CREATE INDEX "access_points_deleted_index" on "access_points" ("deleted");
CREATE TABLE IF NOT EXISTS "alert_device_map" ("id" integer not null primary key autoincrement, "rule_id" integer not null, "device_id" integer not null);
CREATE UNIQUE INDEX "alert_device_map_rule_id_device_id_unique" on "alert_device_map" ("rule_id", "device_id");
CREATE TABLE IF NOT EXISTS "alert_group_map" ("id" integer not null primary key autoincrement, "rule_id" integer not null, "group_id" integer not null);
CREATE UNIQUE INDEX "alert_group_map_rule_id_group_id_unique" on "alert_group_map" ("rule_id", "group_id");
CREATE TABLE IF NOT EXISTS "alert_log" ("id" integer not null primary key autoincrement, "rule_id" integer not null, "device_id" integer not null, "state" integer not null, "details" blob, "time_logged" datetime default CURRENT_TIMESTAMP not null);
CREATE TABLE IF NOT EXISTS "alert_rules" ("id" integer not null primary key autoincrement, "rule" text not null, "severity" varchar check ("severity" in ('ok', 'warning', 'critical')) not null, "extra" varchar not null, "disabled" tinyint(1) not null, "name" varchar not null, "query" text not null, "builder" text not null, "proc" varchar, "invert_map" tinyint(1) not null default '0');
CREATE UNIQUE INDEX "alert_rules_name_unique" on "alert_rules" ("name");
CREATE TABLE IF NOT EXISTS "alert_schedulables" ("item_id" integer not null primary key autoincrement, "schedule_id" integer not null, "alert_schedulable_id" integer not null, "alert_schedulable_type" varchar not null);
CREATE INDEX "schedulable_morph_index" on "alert_schedulables" ("alert_schedulable_type", "alert_schedulable_id");
CREATE INDEX "alert_schedulables_schedule_id_index" on "alert_schedulables" ("schedule_id");
CREATE TABLE IF NOT EXISTS "alert_template_map" ("id" integer not null primary key autoincrement, "alert_templates_id" integer not null, "alert_rule_id" integer not null);
CREATE INDEX "alert_templates_id" on "alert_template_map" ("alert_templates_id", "alert_rule_id");
CREATE TABLE IF NOT EXISTS "alert_templates" ("id" integer not null primary key autoincrement, "name" varchar not null, "template" text not null, "title" varchar, "title_rec" varchar);
CREATE TABLE IF NOT EXISTS "alert_transport_groups" ("transport_group_id" integer not null primary key autoincrement, "transport_group_name" varchar not null);
CREATE TABLE IF NOT EXISTS "alert_transport_map" ("id" integer not null primary key autoincrement, "rule_id" integer not null, "transport_or_group_id" integer not null, "target_type" varchar not null);
CREATE TABLE IF NOT EXISTS "alert_transports" ("transport_id" integer not null primary key autoincrement, "transport_name" varchar not null, "transport_type" varchar not null default 'mail', "is_default" tinyint(1) not null default '0', "transport_config" text);
CREATE TABLE IF NOT EXISTS "alerts" ("id" integer not null primary key autoincrement, "device_id" integer not null, "rule_id" integer not null, "state" integer not null, "alerted" integer not null, "open" integer not null, "note" text, "timestamp" datetime default CURRENT_TIMESTAMP not null, "info" text not null);
CREATE TABLE IF NOT EXISTS "api_tokens" ("id" integer not null primary key autoincrement, "user_id" integer not null, "token_hash" varchar, "description" varchar not null, "disabled" tinyint(1) not null default '0');
CREATE TABLE IF NOT EXISTS "applications" ("app_id" integer not null primary key autoincrement, "device_id" integer not null, "app_type" varchar not null, "app_state" varchar not null default 'UNKNOWN', "discovered" integer not null default '0', "app_state_prev" varchar, "app_status" varchar not null, "timestamp" datetime default CURRENT_TIMESTAMP not null, "app_instance" varchar not null);
CREATE UNIQUE INDEX "applications_device_id_app_type_unique" on "applications" ("device_id", "app_type");
CREATE TABLE IF NOT EXISTS "authlog" ("id" integer not null primary key autoincrement, "datetime" datetime default CURRENT_TIMESTAMP not null, "user" text not null, "address" text not null, "result" text not null);
CREATE TABLE IF NOT EXISTS "bgpPeers_cbgp" ("device_id" integer not null, "bgpPeerIdentifier" varchar not null, "afi" varchar not null, "safi" varchar not null, "AcceptedPrefixes" integer not null, "DeniedPrefixes" integer not null, "PrefixAdminLimit" integer not null, "PrefixThreshold" integer not null, "PrefixClearThreshold" integer not null, "AdvertisedPrefixes" integer not null, "SuppressedPrefixes" integer not null, "WithdrawnPrefixes" integer not null, "AcceptedPrefixes_delta" integer not null, "AcceptedPrefixes_prev" integer not null, "DeniedPrefixes_delta" integer not null, "DeniedPrefixes_prev" integer not null, "AdvertisedPrefixes_delta" integer not null, "AdvertisedPrefixes_prev" integer not null, "SuppressedPrefixes_delta" integer not null, "SuppressedPrefixes_prev" integer not null, "WithdrawnPrefixes_delta" integer not null, "WithdrawnPrefixes_prev" integer not null, "context_name" varchar);
CREATE TABLE IF NOT EXISTS "bgpPeers" ("bgpPeer_id" integer not null primary key autoincrement, "device_id" integer not null, "astext" varchar not null, "bgpPeerIdentifier" text not null, "bgpPeerRemoteAs" integer not null, "bgpPeerState" text not null, "bgpPeerAdminStatus" text not null, "bgpLocalAddr" text not null, "bgpPeerRemoteAddr" text not null, "bgpPeerDescr" varchar not null default '', "bgpPeerInUpdates" integer not null, "bgpPeerOutUpdates" integer not null, "bgpPeerInTotalMessages" integer not null, "bgpPeerOutTotalMessages" integer not null, "bgpPeerFsmEstablishedTime" integer not null, "bgpPeerInUpdateElapsedTime" integer not null, "context_name" varchar, "vrf_id" integer, "bgpPeerLastErrorCode" integer, "bgpPeerLastErrorSubCode" integer, "bgpPeerLastErrorText" varchar);
CREATE INDEX "bgppeers_device_id_context_name_index" on "bgpPeers" ("device_id", "context_name");
CREATE TABLE IF NOT EXISTS "bill_data" ("bill_id" integer not null, "timestamp" datetime not null, "period" integer not null, "delta" integer not null, "in_delta" integer not null, "out_delta" integer not null, primary key ("bill_id", "timestamp"));
CREATE INDEX "bill_data_bill_id_index" on "bill_data" ("bill_id");
CREATE TABLE IF NOT EXISTS "bill_history" ("bill_hist_id" integer not null primary key autoincrement, "bill_id" integer not null, "updated" datetime default CURRENT_TIMESTAMP not null, "bill_datefrom" datetime not null, "bill_dateto" datetime not null, "bill_type" text not null, "bill_allowed" integer not null, "bill_used" integer not null, "bill_overuse" integer not null, "bill_percent" numeric not null, "rate_95th_in" integer not null, "rate_95th_out" integer not null, "rate_95th" integer not null, "dir_95th" varchar not null, "rate_average" integer not null, "rate_average_in" integer not null, "rate_average_out" integer not null, "traf_in" integer not null, "traf_out" integer not null, "traf_total" integer not null, "pdf" blob);
CREATE TABLE IF NOT EXISTS "bill_ports" ("id" integer not null primary key autoincrement, "bill_id" integer not null, "port_id" integer not null, "bill_port_autoadded" tinyint(1) not null default '0');
CREATE TABLE IF NOT EXISTS "bills" ("bill_id" integer not null primary key autoincrement, "bill_name" text not null, "bill_type" text not null, "bill_cdr" integer, "bill_day" integer not null default '1', "bill_quota" integer, "rate_95th_in" integer not null, "rate_95th_out" integer not null, "rate_95th" integer not null, "dir_95th" varchar not null, "total_data" integer not null, "total_data_in" integer not null, "total_data_out" integer not null, "rate_average_in" integer not null, "rate_average_out" integer not null, "rate_average" integer not null, "bill_last_calc" datetime not null, "bill_custid" varchar not null, "bill_ref" varchar not null, "bill_notes" varchar not null, "bill_autoadded" tinyint(1) not null);
CREATE TABLE IF NOT EXISTS "callback" ("callback_id" integer not null primary key autoincrement, "name" varchar not null, "value" varchar not null);
CREATE TABLE IF NOT EXISTS "cef_switching" ("cef_switching_id" integer not null primary key autoincrement, "device_id" integer not null, "entPhysicalIndex" integer not null, "afi" varchar not null, "cef_index" integer not null, "cef_path" varchar not null, "drop" integer not null, "punt" integer not null, "punt2host" integer not null, "drop_prev" integer not null, "punt_prev" integer not null, "punt2host_prev" integer not null, "updated" integer not null, "updated_prev" integer not null);
CREATE UNIQUE INDEX "cef_switching_device_id_entphysicalindex_afi_cef_index_unique" on "cef_switching" ("device_id", "entPhysicalIndex", "afi", "cef_index");
CREATE TABLE IF NOT EXISTS "ciscoASA" ("ciscoASA_id" integer not null primary key autoincrement, "device_id" integer not null, "oid" varchar not null, "data" integer not null, "high_alert" integer not null, "low_alert" integer not null, "disabled" integer not null default '0');
CREATE INDEX "ciscoasa_device_id_index" on "ciscoASA" ("device_id");
CREATE TABLE IF NOT EXISTS "component_prefs" ("id" integer not null primary key autoincrement, "component" integer not null, "attribute" varchar not null, "value" text not null);
CREATE INDEX "component_prefs_component_index" on "component_prefs" ("component");
CREATE INDEX "component_device_id_index" on "component" ("device_id");
CREATE INDEX "component_type_index" on "component" ("type");
CREATE TABLE IF NOT EXISTS "customers" ("customer_id" integer not null primary key autoincrement, "username" varchar not null, "password" varchar not null, "string" varchar not null, "level" integer not null default '0');
CREATE UNIQUE INDEX "customers_username_unique" on "customers" ("username");
CREATE TABLE IF NOT EXISTS "dashboards" ("dashboard_id" integer not null primary key autoincrement, "user_id" integer not null default '0', "dashboard_name" varchar not null, "access" tinyint(1) not null default '0');
CREATE TABLE IF NOT EXISTS "dbSchema" ("version" integer not null default '0', primary key ("version"));
CREATE INDEX "device_graphs_device_id_index" on "device_graphs" ("device_id");
CREATE TABLE IF NOT EXISTS "device_group_device" ("device_group_id" integer not null, "device_id" integer not null, primary key ("device_group_id", "device_id"));
CREATE INDEX "device_group_device_device_group_id_index" on "device_group_device" ("device_group_id");
CREATE INDEX "device_group_device_device_id_index" on "device_group_device" ("device_id");
CREATE TABLE IF NOT EXISTS "device_perf" ("id" integer not null primary key autoincrement, "device_id" integer not null, "timestamp" datetime not null, "xmt" integer not null, "rcv" integer not null, "loss" integer not null, "min" float not null, "max" float not null, "avg" float not null, "debug" text);
CREATE INDEX "device_perf_device_id_index" on "device_perf" ("device_id");
CREATE TABLE IF NOT EXISTS "device_relationships" ("parent_device_id" integer not null default '0', "child_device_id" integer not null, primary key ("parent_device_id", "child_device_id"));
CREATE INDEX "device_relationships_child_device_id_index" on "device_relationships" ("child_device_id");
CREATE TABLE IF NOT EXISTS "devices_attribs" ("attrib_id" integer not null primary key autoincrement, "device_id" integer not null, "attrib_type" varchar not null, "attrib_value" text not null, "updated" datetime default CURRENT_TIMESTAMP not null);
CREATE INDEX "devices_attribs_device_id_index" on "devices_attribs" ("device_id");
CREATE TABLE IF NOT EXISTS "devices_perms" ("id" integer not null primary key autoincrement, "user_id" integer not null, "device_id" integer not null);
CREATE INDEX "devices_perms_user_id_index" on "devices_perms" ("user_id");
CREATE TABLE IF NOT EXISTS "entPhysical_state" ("id" integer not null primary key autoincrement, "device_id" integer not null, "entPhysicalIndex" varchar not null, "subindex" varchar, "group" varchar not null, "key" varchar not null, "value" varchar not null);
CREATE TABLE IF NOT EXISTS "entPhysical" ("entPhysical_id" integer not null primary key autoincrement, "device_id" integer not null, "entPhysicalIndex" integer not null, "entPhysicalDescr" text not null, "entPhysicalClass" text not null, "entPhysicalName" text not null, "entPhysicalHardwareRev" varchar, "entPhysicalFirmwareRev" varchar, "entPhysicalSoftwareRev" varchar, "entPhysicalAlias" varchar, "entPhysicalAssetID" varchar, "entPhysicalIsFRU" varchar, "entPhysicalModelName" text not null, "entPhysicalVendorType" text, "entPhysicalSerialNum" text not null, "entPhysicalContainedIn" integer not null, "entPhysicalParentRelPos" integer not null, "entPhysicalMfgName" text not null, "ifIndex" integer);
CREATE TABLE IF NOT EXISTS "graph_types" ("graph_type" varchar not null, "graph_subtype" varchar not null, "graph_section" varchar not null, "graph_descr" varchar, "graph_order" integer not null, primary key ("graph_type", "graph_subtype", "graph_section"));
CREATE TABLE IF NOT EXISTS "hrDevice" ("hrDevice_id" integer not null primary key autoincrement, "device_id" integer not null, "hrDeviceIndex" integer not null, "hrDeviceDescr" text not null, "hrDeviceType" text not null, "hrDeviceErrors" integer not null default '0', "hrDeviceStatus" text not null, "hrProcessorLoad" integer);
CREATE INDEX "hrdevice_device_id_index" on "hrDevice" ("device_id");
CREATE TABLE IF NOT EXISTS "ipsec_tunnels" ("tunnel_id" integer not null primary key autoincrement, "device_id" integer not null, "peer_port" integer not null, "peer_addr" varchar not null, "local_addr" varchar not null, "local_port" integer not null, "tunnel_name" varchar not null, "tunnel_status" varchar not null);
CREATE UNIQUE INDEX "ipsec_tunnels_device_id_peer_addr_unique" on "ipsec_tunnels" ("device_id", "peer_addr");
CREATE TABLE IF NOT EXISTS "ipv4_addresses" ("ipv4_address_id" integer not null primary key autoincrement, "ipv4_address" varchar not null, "ipv4_prefixlen" integer not null, "ipv4_network_id" varchar not null, "port_id" integer not null, "context_name" varchar);
CREATE TABLE IF NOT EXISTS "ipv4_mac" ("id" integer not null primary key autoincrement, "port_id" integer not null, "device_id" integer, "mac_address" varchar not null, "ipv4_address" varchar not null, "context_name" varchar not null);
CREATE TABLE IF NOT EXISTS "ipv4_networks" ("ipv4_network_id" integer not null primary key autoincrement, "ipv4_network" varchar not null, "context_name" varchar);
CREATE TABLE IF NOT EXISTS "ipv6_addresses" ("ipv6_address_id" integer not null primary key autoincrement, "ipv6_address" varchar not null, "ipv6_compressed" varchar not null, "ipv6_prefixlen" integer not null, "ipv6_origin" varchar not null, "ipv6_network_id" varchar not null, "port_id" integer not null, "context_name" varchar);
CREATE TABLE IF NOT EXISTS "ipv6_networks" ("ipv6_network_id" integer not null primary key autoincrement, "ipv6_network" varchar not null, "context_name" varchar);
CREATE TABLE IF NOT EXISTS "juniAtmVp" ("id" integer not null primary key autoincrement, "juniAtmVp_id" integer not null, "port_id" integer not null, "vp_id" integer not null, "vp_descr" varchar not null);
CREATE INDEX "juniatmvp_port_id_index" on "juniAtmVp" ("port_id");
CREATE INDEX "local_device_id" on "links" ("local_device_id", "remote_device_id");
CREATE INDEX "links_local_port_id_index" on "links" ("local_port_id");
CREATE INDEX "links_remote_port_id_index" on "links" ("remote_port_id");
CREATE TABLE IF NOT EXISTS "loadbalancer_rservers" ("rserver_id" integer not null primary key autoincrement, "farm_id" varchar not null, "device_id" integer not null, "StateDescr" varchar not null);
CREATE TABLE IF NOT EXISTS "loadbalancer_vservers" ("id" integer not null primary key autoincrement, "classmap_id" integer not null, "classmap" varchar not null, "serverstate" varchar not null, "device_id" integer not null);
CREATE INDEX "loadbalancer_vservers_device_id_index" on "loadbalancer_vservers" ("device_id");
CREATE TABLE IF NOT EXISTS "locations" ("id" integer not null primary key autoincrement, "location" varchar not null, "lat" float, "lng" float, "timestamp" datetime not null);
CREATE INDEX "mac_accounting_port_id_index" on "mac_accounting" ("port_id");
CREATE TABLE IF NOT EXISTS "mefinfo" ("id" integer not null primary key autoincrement, "device_id" integer not null, "mefID" integer not null, "mefType" varchar not null, "mefIdent" varchar not null, "mefMTU" integer not null default '1500', "mefAdmState" varchar not null, "mefRowState" varchar not null);
CREATE INDEX "mefinfo_device_id_index" on "mefinfo" ("device_id");
CREATE INDEX "mefinfo_mefid_index" on "mefinfo" ("mefID");
CREATE TABLE IF NOT EXISTS "munin_plugins_ds" ("mplug_id" integer not null, "ds_name" varchar not null, "ds_type" varchar check ("ds_type" in ('COUNTER', 'ABSOLUTE', 'DERIVE', 'GAUGE')) not null default 'GAUGE', "ds_label" varchar not null, "ds_cdef" varchar not null, "ds_draw" varchar not null, "ds_graph" varchar check ("ds_graph" in ('no', 'yes')) not null default 'yes', "ds_info" varchar not null, "ds_extinfo" text not null, "ds_max" varchar not null, "ds_min" varchar not null, "ds_negative" varchar not null, "ds_warning" varchar not null, "ds_critical" varchar not null, "ds_colour" varchar not null, "ds_sum" text not null, "ds_stack" text not null, "ds_line" varchar not null);
CREATE UNIQUE INDEX "munin_plugins_ds_mplug_id_ds_name_unique" on "munin_plugins_ds" ("mplug_id", "ds_name");
CREATE UNIQUE INDEX "munin_plugins_device_id_mplug_type_unique" on "munin_plugins" ("device_id", "mplug_type");
CREATE INDEX "munin_plugins_device_id_index" on "munin_plugins" ("device_id");
CREATE TABLE IF NOT EXISTS "netscaler_vservers" ("vsvr_id" integer not null primary key autoincrement, "device_id" integer not null, "vsvr_name" varchar not null, "vsvr_ip" varchar not null, "vsvr_port" integer not null, "vsvr_type" varchar not null, "vsvr_state" varchar not null, "vsvr_clients" integer not null, "vsvr_server" integer not null, "vsvr_req_rate" integer not null, "vsvr_bps_in" integer not null, "vsvr_bps_out" integer not null);
CREATE TABLE IF NOT EXISTS "notifications_attribs" ("attrib_id" integer not null primary key autoincrement, "notifications_id" integer not null, "user_id" integer not null, "key" varchar not null default '', "value" varchar not null default '');
CREATE TABLE IF NOT EXISTS "notifications" ("notifications_id" integer not null primary key autoincrement, "title" varchar not null default '', "body" text not null, "severity" integer default '0', "source" varchar not null default '', "checksum" varchar not null, "datetime" datetime not null default '1970-01-02 00:00:00');
CREATE TABLE IF NOT EXISTS "ospf_instances" ("id" integer not null primary key autoincrement, "device_id" integer not null, "ospf_instance_id" integer not null, "ospfRouterId" varchar not null, "ospfAdminStat" varchar not null, "ospfVersionNumber" varchar not null, "ospfAreaBdrRtrStatus" varchar not null, "ospfASBdrRtrStatus" varchar not null, "ospfExternLsaCount" integer not null, "ospfExternLsaCksumSum" integer not null, "ospfTOSSupport" varchar not null, "ospfOriginateNewLsas" integer not null, "ospfRxNewLsas" integer not null, "ospfExtLsdbLimit" integer, "ospfMulticastExtensions" integer, "ospfExitOverflowInterval" integer, "ospfDemandExtensions" varchar, "context_name" varchar);
CREATE UNIQUE INDEX "ospf_instances_device_id_ospf_instance_id_context_name_unique" on "ospf_instances" ("device_id", "ospf_instance_id", "context_name");
CREATE TABLE IF NOT EXISTS "ospf_nbrs" ("id" integer not null primary key autoincrement, "device_id" integer not null, "port_id" integer, "ospf_nbr_id" varchar not null, "ospfNbrIpAddr" varchar not null, "ospfNbrAddressLessIndex" integer not null, "ospfNbrRtrId" varchar not null, "ospfNbrOptions" integer not null, "ospfNbrPriority" integer not null, "ospfNbrState" varchar not null, "ospfNbrEvents" integer not null, "ospfNbrLsRetransQLen" integer not null, "ospfNbmaNbrStatus" varchar not null, "ospfNbmaNbrPermanence" varchar not null, "ospfNbrHelloSuppressed" varchar not null, "context_name" varchar);
CREATE TABLE IF NOT EXISTS "packages" ("pkg_id" integer not null primary key autoincrement, "device_id" integer not null, "name" varchar not null, "manager" varchar not null default '1', "status" tinyint(1) not null, "version" varchar not null, "build" varchar not null, "arch" varchar not null, "size" integer);
CREATE TABLE IF NOT EXISTS "pdb_ix" ("pdb_ix_id" integer not null primary key autoincrement, "ix_id" integer not null, "name" varchar not null, "asn" integer not null, "timestamp" integer not null);
CREATE TABLE IF NOT EXISTS "perf_times" ("id" integer not null primary key autoincrement, "type" varchar not null, "doing" varchar not null, "start" integer not null, "duration" float not null, "devices" integer not null, "poller" varchar not null);
CREATE INDEX "perf_times_type_index" on "perf_times" ("type");
CREATE TABLE IF NOT EXISTS "plugins" ("plugin_id" integer not null primary key autoincrement, "plugin_name" varchar not null, "plugin_active" integer not null);
CREATE TABLE IF NOT EXISTS "poller_cluster_stats" ("id" integer not null primary key autoincrement, "parent_poller" integer not null default '0', "poller_type" varchar not null default '', "depth" integer not null, "devices" integer not null, "worker_seconds" float not null, "workers" integer not null, "frequency" integer not null);
CREATE UNIQUE INDEX "poller_cluster_stats_parent_poller_poller_type_unique" on "poller_cluster_stats" ("parent_poller", "poller_type");
CREATE UNIQUE INDEX "poller_cluster_node_id_unique" on "poller_cluster" ("node_id");
CREATE TABLE IF NOT EXISTS "poller_groups" ("id" integer not null primary key autoincrement, "group_name" varchar not null, "descr" varchar not null);
CREATE TABLE IF NOT EXISTS "pollers" ("id" integer not null primary key autoincrement, "poller_name" varchar not null, "last_polled" datetime not null, "devices" integer not null, "time_taken" float not null);
CREATE UNIQUE INDEX "pollers_poller_name_unique" on "pollers" ("poller_name");
CREATE TABLE IF NOT EXISTS "ports_adsl" ("port_id" integer not null, "port_adsl_updated" datetime default CURRENT_TIMESTAMP not null, "adslLineCoding" varchar not null, "adslLineType" varchar not null, "adslAtucInvVendorID" varchar not null, "adslAtucInvVersionNumber" varchar not null, "adslAtucCurrSnrMgn" numeric not null, "adslAtucCurrAtn" numeric not null, "adslAtucCurrOutputPwr" numeric not null, "adslAtucCurrAttainableRate" integer not null, "adslAtucChanCurrTxRate" integer not null, "adslAturInvSerialNumber" varchar not null, "adslAturInvVendorID" varchar not null, "adslAturInvVersionNumber" varchar not null, "adslAturChanCurrTxRate" integer not null, "adslAturCurrSnrMgn" numeric not null, "adslAturCurrAtn" numeric not null, "adslAturCurrOutputPwr" numeric not null, "adslAturCurrAttainableRate" integer not null);
CREATE UNIQUE INDEX "ports_adsl_port_id_unique" on "ports_adsl" ("port_id");
CREATE TABLE IF NOT EXISTS "ports_fdb" ("ports_fdb_id" integer not null primary key autoincrement, "port_id" integer not null, "mac_address" varchar not null, "vlan_id" integer not null, "device_id" integer not null, "created_at" datetime, "updated_at" datetime);
CREATE INDEX "ports_fdb_port_id_index" on "ports_fdb" ("port_id");
CREATE INDEX "ports_fdb_mac_address_index" on "ports_fdb" ("mac_address");
CREATE INDEX "ports_fdb_vlan_id_index" on "ports_fdb" ("vlan_id");
CREATE INDEX "ports_fdb_device_id_index" on "ports_fdb" ("device_id");
CREATE TABLE IF NOT EXISTS "ports_perms" ("id" integer not null primary key autoincrement, "user_id" integer not null, "port_id" integer not null);
CREATE TABLE IF NOT EXISTS "ports_stack" ("device_id" integer not null, "port_id_high" integer not null, "port_id_low" integer not null, "ifStackStatus" varchar not null);
CREATE UNIQUE INDEX "ports_stack_device_id_port_id_high_port_id_low_unique" on "ports_stack" ("device_id", "port_id_high", "port_id_low");
CREATE TABLE IF NOT EXISTS "ports_stp" ("port_stp_id" integer not null primary key autoincrement, "device_id" integer not null, "port_id" integer not null, "priority" integer not null, "state" varchar not null, "enable" varchar not null, "pathCost" integer not null, "designatedRoot" varchar not null, "designatedCost" integer not null, "designatedBridge" varchar not null, "designatedPort" integer not null, "forwardTransitions" integer not null);
CREATE UNIQUE INDEX "ports_stp_device_id_port_id_unique" on "ports_stp" ("device_id", "port_id");
CREATE UNIQUE INDEX "ports_device_id_ifindex_unique" on "ports" ("device_id", "ifIndex");
CREATE INDEX "ports_ifdescr_index" on "ports" ("ifDescr");
CREATE TABLE IF NOT EXISTS "ports_vlans" ("port_vlan_id" integer not null primary key autoincrement, "device_id" integer not null, "port_id" integer not null, "vlan" integer not null, "baseport" integer not null, "priority" integer not null, "state" varchar not null, "cost" integer not null, "untagged" tinyint(1) not null default '0');
CREATE UNIQUE INDEX "ports_vlans_device_id_port_id_vlan_unique" on "ports_vlans" ("device_id", "port_id", "vlan");
CREATE TABLE IF NOT EXISTS "processes" ("id" integer not null primary key autoincrement, "device_id" integer not null, "pid" integer not null, "vsz" integer not null, "rss" integer not null, "cputime" varchar not null, "user" varchar not null, "command" text not null);
CREATE INDEX "processes_device_id_index" on "processes" ("device_id");
CREATE TABLE IF NOT EXISTS "processors" ("processor_id" integer not null primary key autoincrement, "entPhysicalIndex" integer not null default '0', "hrDeviceIndex" integer, "device_id" integer not null, "processor_oid" varchar not null, "processor_index" varchar not null, "processor_type" varchar not null, "processor_usage" integer not null, "processor_descr" varchar not null, "processor_precision" integer not null default '1', "processor_perc_warn" integer default '75');
CREATE INDEX "processors_device_id_index" on "processors" ("device_id");
CREATE TABLE IF NOT EXISTS "proxmox_ports" ("id" integer not null primary key autoincrement, "vm_id" integer not null, "port" varchar not null, "last_seen" datetime default CURRENT_TIMESTAMP not null);
CREATE UNIQUE INDEX "proxmox_ports_vm_id_port_unique" on "proxmox_ports" ("vm_id", "port");
CREATE TABLE IF NOT EXISTS "proxmox" ("id" integer not null primary key autoincrement, "device_id" integer not null default '0', "vmid" integer not null, "cluster" varchar not null, "description" varchar, "last_seen" datetime default CURRENT_TIMESTAMP not null);
CREATE UNIQUE INDEX "proxmox_cluster_vmid_unique" on "proxmox" ("cluster", "vmid");
CREATE TABLE IF NOT EXISTS "pseudowires" ("pseudowire_id" integer not null primary key autoincrement, "device_id" integer not null, "port_id" integer not null, "peer_device_id" integer not null, "peer_ldp_id" integer not null, "cpwVcID" integer not null, "cpwOid" integer not null, "pw_type" varchar not null, "pw_psntype" varchar not null, "pw_local_mtu" integer not null, "pw_peer_mtu" integer not null, "pw_descr" varchar not null);
CREATE INDEX "sensors_sensor_class_index" on "sensors" ("sensor_class");
CREATE INDEX "sensors_device_id_index" on "sensors" ("device_id");
CREATE INDEX "sensors_sensor_type_index" on "sensors" ("sensor_type");
CREATE TABLE IF NOT EXISTS "sensors_to_state_indexes" ("sensors_to_state_translations_id" integer not null primary key autoincrement, "sensor_id" integer not null, "state_index_id" integer not null);
CREATE UNIQUE INDEX "sensors_to_state_indexes_sensor_id_state_index_id_unique" on "sensors_to_state_indexes" ("sensor_id", "state_index_id");
CREATE INDEX "sensors_to_state_indexes_state_index_id_index" on "sensors_to_state_indexes" ("state_index_id");
CREATE TABLE IF NOT EXISTS "session" ("session_id" integer not null primary key autoincrement, "session_username" varchar not null, "session_value" varchar not null, "session_token" varchar not null, "session_auth" varchar not null, "session_expiry" integer not null);
CREATE UNIQUE INDEX "session_session_value_unique" on "session" ("session_value");
CREATE TABLE IF NOT EXISTS "slas" ("sla_id" integer not null primary key autoincrement, "device_id" integer not null, "sla_nr" integer not null, "owner" varchar not null, "tag" varchar not null, "rtt_type" varchar not null, "status" tinyint(1) not null, "opstatus" tinyint(1) not null default '0', "deleted" tinyint(1) not null default '0');
CREATE UNIQUE INDEX "slas_device_id_sla_nr_unique" on "slas" ("device_id", "sla_nr");
CREATE INDEX "slas_device_id_index" on "slas" ("device_id");
CREATE TABLE IF NOT EXISTS "state_indexes" ("state_index_id" integer not null primary key autoincrement, "state_name" varchar not null);
CREATE UNIQUE INDEX "state_indexes_state_name_unique" on "state_indexes" ("state_name");
CREATE TABLE IF NOT EXISTS "state_translations" ("state_translation_id" integer not null primary key autoincrement, "state_index_id" integer not null, "state_descr" varchar not null, "state_draw_graph" tinyint(1) not null, "state_value" integer not null default '0', "state_generic_value" tinyint(1) not null, "state_lastupdated" datetime default CURRENT_TIMESTAMP not null);
CREATE UNIQUE INDEX "state_translations_state_index_id_state_value_unique" on "state_translations" ("state_index_id", "state_value");
CREATE TABLE IF NOT EXISTS "storage" ("storage_id" integer not null primary key autoincrement, "device_id" integer not null, "storage_mib" varchar not null, "storage_index" varchar, "storage_type" varchar, "storage_descr" text not null, "storage_size" integer not null, "storage_units" integer not null, "storage_used" integer not null default '0', "storage_free" integer not null default '0', "storage_perc" integer not null default '0', "storage_perc_warn" integer default '60', "storage_deleted" tinyint(1) not null default '0');
CREATE TABLE IF NOT EXISTS "stp" ("stp_id" integer not null primary key autoincrement, "device_id" integer not null, "rootBridge" tinyint(1) not null, "bridgeAddress" varchar not null, "protocolSpecification" varchar not null, "priority" integer not null, "timeSinceTopologyChange" varchar not null, "topChanges" integer not null, "designatedRoot" varchar not null, "rootCost" integer not null, "rootPort" integer, "maxAge" integer not null, "helloTime" integer not null, "holdTime" integer not null, "forwardDelay" integer not null, "bridgeMaxAge" integer not null, "bridgeHelloTime" integer not null, "bridgeForwardDelay" integer not null);
CREATE INDEX "syslog_priority_level_index" on "syslog" ("priority", "level");
CREATE INDEX "syslog_device_id_timestamp_index" on "syslog" ("device_id", "timestamp");
CREATE INDEX "syslog_device_id_index" on "syslog" ("device_id");
CREATE INDEX "syslog_timestamp_index" on "syslog" ("timestamp");
CREATE INDEX "syslog_program_index" on "syslog" ("program");
CREATE TABLE IF NOT EXISTS "tnmsneinfo" ("id" integer not null primary key autoincrement, "device_id" integer not null, "neID" integer not null, "neType" varchar not null, "neName" varchar not null, "neLocation" varchar not null, "neAlarm" varchar not null, "neOpMode" varchar not null, "neOpState" varchar not null);
CREATE INDEX "tnmsneinfo_device_id_index" on "tnmsneinfo" ("device_id");
CREATE INDEX "tnmsneinfo_neid_index" on "tnmsneinfo" ("neID");
CREATE INDEX "toner_device_id_index" on "toner" ("device_id");
CREATE TABLE IF NOT EXISTS "transport_group_transport" ("id" integer not null primary key autoincrement, "transport_group_id" integer not null, "transport_id" integer not null);
CREATE TABLE IF NOT EXISTS "ucd_diskio" ("diskio_id" integer not null primary key autoincrement, "device_id" integer not null, "diskio_index" integer not null, "diskio_descr" varchar not null);
CREATE INDEX "ucd_diskio_device_id_index" on "ucd_diskio" ("device_id");
CREATE TABLE IF NOT EXISTS "users_prefs" ("user_id" integer not null, "pref" varchar not null, "value" varchar not null);
CREATE UNIQUE INDEX "users_prefs_user_id_pref_unique" on "users_prefs" ("user_id", "pref");
CREATE UNIQUE INDEX "users_auth_type_username_unique" on "users" ("auth_type", "username");
CREATE TABLE IF NOT EXISTS "users_widgets" ("user_widget_id" integer not null primary key autoincrement, "user_id" integer not null, "widget_id" integer not null, "col" integer not null, "row" integer not null, "size_x" integer not null, "size_y" integer not null, "title" varchar not null, "refresh" integer not null default '60', "settings" text not null, "dashboard_id" integer not null);
CREATE INDEX "user_id" on "users_widgets" ("user_id", "widget_id");
CREATE TABLE IF NOT EXISTS "vrfs" ("vrf_id" integer not null primary key autoincrement, "vrf_oid" varchar not null, "vrf_name" varchar, "mplsVpnVrfRouteDistinguisher" varchar, "mplsVpnVrfDescription" text not null, "device_id" integer not null, "bgpLocalAs" integer);
CREATE INDEX "vrfs_device_id_index" on "vrfs" ("device_id");
CREATE TABLE IF NOT EXISTS "widgets" ("widget_id" integer not null primary key autoincrement, "widget_title" varchar not null, "widget" varchar not null, "base_dimensions" varchar not null);
CREATE UNIQUE INDEX "widgets_widget_unique" on "widgets" ("widget");
CREATE TABLE IF NOT EXISTS "route" ("route_id" integer not null primary key autoincrement, "created_at" datetime, "updated_at" datetime, "device_id" integer not null, "port_id" integer not null, "context_name" varchar, "inetCidrRouteIfIndex" integer not null, "inetCidrRouteType" integer not null, "inetCidrRouteProto" integer not null, "inetCidrRouteNextHopAS" integer not null, "inetCidrRouteMetric1" integer not null, "inetCidrRouteDestType" varchar not null, "inetCidrRouteDest" varchar not null, "inetCidrRouteNextHopType" varchar not null, "inetCidrRouteNextHop" varchar not null, "inetCidrRoutePolicy" varchar not null, "inetCidrRoutePfxLen" integer not null);
CREATE TABLE IF NOT EXISTS "mpls_lsps" ("lsp_id" integer not null primary key autoincrement, "vrf_oid" integer not null, "lsp_oid" integer not null, "device_id" integer not null, "mplsLspRowStatus" varchar check ("mplsLspRowStatus" in ('active', 'notInService', 'notReady', 'createAndGo', 'createAndWait', 'destroy')) not null, "mplsLspLastChange" integer, "mplsLspName" varchar not null, "mplsLspAdminState" varchar check ("mplsLspAdminState" in ('noop', 'inService', 'outOfService')) not null, "mplsLspOperState" varchar check ("mplsLspOperState" in ('unknown', 'inService', 'outOfService', 'transition')) not null, "mplsLspFromAddr" varchar not null, "mplsLspToAddr" varchar not null, "mplsLspType" varchar check ("mplsLspType" in ('unknown', 'dynamic', 'static', 'bypassOnly', 'p2mpLsp', 'p2mpAuto', 'mplsTp', 'meshP2p', 'oneHopP2p', 'srTe', 'meshP2pSrTe', 'oneHopP2pSrTe')) not null, "mplsLspFastReroute" varchar check ("mplsLspFastReroute" in ('true', 'false')) not null, "mplsLspAge" integer, "mplsLspTimeUp" integer, "mplsLspTimeDown" integer, "mplsLspPrimaryTimeUp" integer, "mplsLspTransitions" integer, "mplsLspLastTransition" integer, "mplsLspConfiguredPaths" integer, "mplsLspStandbyPaths" integer, "mplsLspOperationalPaths" integer);
CREATE INDEX "mpls_saps_device_id_index" on "mpls_saps" ("device_id");
CREATE INDEX "notifications_attribs_notifications_id_user_id_index" on "notifications_attribs" ("notifications_id", "user_id");
CREATE TABLE IF NOT EXISTS "devices_group_perms" ("user_id" integer not null, "device_group_id" integer not null, primary key ("device_group_id", "user_id"));
CREATE INDEX "devices_group_perms_user_id_index" on "devices_group_perms" ("user_id");
CREATE INDEX "devices_group_perms_device_group_id_index" on "devices_group_perms" ("device_group_id");
CREATE TABLE mpls_lsp_paths (lsp_path_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, lsp_id INTEGER NOT NULL, path_oid INTEGER NOT NULL, device_id INTEGER NOT NULL, mplsLspPathRowStatus VARCHAR(255) NOT NULL COLLATE BINARY, mplsLspPathLastChange INTEGER NOT NULL, mplsLspPathType VARCHAR(255) NOT NULL COLLATE BINARY, mplsLspPathBandwidth INTEGER NOT NULL, mplsLspPathOperBandwidth INTEGER NOT NULL, mplsLspPathAdminState VARCHAR(255) NOT NULL COLLATE BINARY, mplsLspPathOperState VARCHAR(255) NOT NULL COLLATE BINARY, mplsLspPathState VARCHAR(255) NOT NULL COLLATE BINARY, mplsLspPathFailCode VARCHAR(255) NOT NULL COLLATE BINARY, mplsLspPathFailNodeAddr VARCHAR(255) NOT NULL COLLATE BINARY, mplsLspPathMetric INTEGER NOT NULL, mplsLspPathOperMetric INTEGER UNSIGNED DEFAULT NULL, mplsLspPathTimeUp INTEGER DEFAULT NULL, mplsLspPathTimeDown INTEGER DEFAULT NULL, mplsLspPathTransitionCount INTEGER DEFAULT NULL, mplsLspPathTunnelARHopListIndex INTEGER DEFAULT NULL, mplsLspPathTunnelCHopListIndex INTEGER DEFAULT NULL);
CREATE INDEX mpls_lsp_paths_device_id_index ON mpls_lsp_paths (device_id);
CREATE TABLE IF NOT EXISTS "alert_location_map" ("id" integer not null primary key autoincrement, "rule_id" integer not null, "location_id" integer not null);
CREATE UNIQUE INDEX "alert_location_map_rule_id_location_id_uindex" on "alert_location_map" ("rule_id", "location_id");
CREATE TABLE alert_schedule (schedule_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, recurring BOOLEAN DEFAULT '0' NOT NULL, start DATETIME DEFAULT '1970-01-02 00:00:01' NOT NULL, "end" DATETIME DEFAULT '1970-01-02 00:00:01' NOT NULL, recurring_day VARCHAR(255) DEFAULT NULL COLLATE BINARY, title VARCHAR(255) NOT NULL COLLATE BINARY, notes CLOB NOT NULL COLLATE BINARY);
CREATE TABLE application_metrics (app_id INTEGER NOT NULL, value DOUBLE PRECISION DEFAULT NULL, value_prev DOUBLE PRECISION DEFAULT NULL, metric VARCHAR(64) NOT NULL COLLATE BINARY);
CREATE UNIQUE INDEX application_metrics_app_id_metric_unique ON application_metrics (app_id, metric);
CREATE TABLE availability (availability_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, device_id INTEGER NOT NULL, duration INTEGER NOT NULL, availability_perc NUMERIC(9, 6) DEFAULT '0' NOT NULL);
CREATE INDEX availability_device_id_index ON availability (device_id);
CREATE UNIQUE INDEX availability_device_id_duration_unique ON availability (device_id, duration);
CREATE TABLE IF NOT EXISTS "service_templates_device_group" ("service_template_id" integer not null, "device_group_id" integer not null, primary key ("service_template_id", "device_group_id"));
CREATE INDEX "service_templates_device_group_service_template_id_index" on "service_templates_device_group" ("service_template_id");
CREATE INDEX "service_templates_device_group_device_group_id_index" on "service_templates_device_group" ("device_group_id");
CREATE TABLE IF NOT EXISTS "service_templates_device" ("service_template_id" integer not null, "device_id" integer not null, primary key ("service_template_id", "device_id"));
CREATE INDEX "service_templates_device_service_template_id_index" on "service_templates_device" ("service_template_id");
CREATE INDEX "service_templates_device_device_id_index" on "service_templates_device" ("device_id");
CREATE TABLE IF NOT EXISTS "service_templates" ("id" integer not null primary key autoincrement, "ip" text, "type" varchar not null, "dtype" varchar not null default 'static', "dgtype" varchar not null default 'static', "drules" text, "dgrules" text, "desc" text, "param" text, "ignore" tinyint(1) not null default '0', "changed" datetime default CURRENT_TIMESTAMP not null, "disabled" tinyint(1) not null default '0', "name" varchar not null);