permit DB schema upgrades from any 0.x and 1.x ver
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
* [#69] Add search by layers to device search
|
* [#69] Add search by layers to device search
|
||||||
* [#77] Log user access
|
* [#77] Log user access
|
||||||
* Try to help users more easily get a default login
|
* Try to help users more easily get a default login
|
||||||
|
* Support upgrade from Netdisco version 0.x
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ __PACKAGE__->load_namespaces(
|
|||||||
default_resultset_class => 'ResultSet',
|
default_resultset_class => 'ResultSet',
|
||||||
);
|
);
|
||||||
|
|
||||||
our $VERSION = 34; # schema version used for upgrades, keep as integer
|
our $VERSION = 38; # schema version used for upgrades, keep as integer
|
||||||
|
|
||||||
use Path::Class;
|
use Path::Class;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
|
|||||||
@@ -1,425 +1,372 @@
|
|||||||
--
|
BEGIN;
|
||||||
-- Created by SQL::Translator::Producer::PostgreSQL
|
|
||||||
-- Created on Wed Oct 10 14:24:20 2012
|
-- admin table - Queue for admin tasks sent from front-end for back-end processing.
|
||||||
--
|
|
||||||
--
|
CREATE TABLE admin (
|
||||||
-- Table: admin.
|
job serial,
|
||||||
--
|
entered TIMESTAMP DEFAULT now(),
|
||||||
CREATE TABLE "admin" (
|
started TIMESTAMP,
|
||||||
"job" serial NOT NULL,
|
finished TIMESTAMP,
|
||||||
"entered" timestamp DEFAULT current_timestamp,
|
device inet,
|
||||||
"started" timestamp,
|
port text,
|
||||||
"finished" timestamp,
|
action text,
|
||||||
"device" inet,
|
subaction text,
|
||||||
"port" text,
|
status text,
|
||||||
"action" text,
|
username text,
|
||||||
"subaction" text,
|
userip inet,
|
||||||
"status" text,
|
log text,
|
||||||
"username" text,
|
debug boolean
|
||||||
"userip" inet,
|
);
|
||||||
"log" text,
|
|
||||||
"debug" boolean
|
CREATE INDEX idx_admin_entered ON admin(entered);
|
||||||
|
CREATE INDEX idx_admin_status ON admin(status);
|
||||||
|
CREATE INDEX idx_admin_action ON admin(action);
|
||||||
|
|
||||||
|
CREATE TABLE device (
|
||||||
|
ip inet PRIMARY KEY,
|
||||||
|
creation TIMESTAMP DEFAULT now(),
|
||||||
|
dns text,
|
||||||
|
description text,
|
||||||
|
uptime bigint,
|
||||||
|
contact text,
|
||||||
|
name text,
|
||||||
|
location text,
|
||||||
|
layers varchar(8),
|
||||||
|
ports integer,
|
||||||
|
mac macaddr,
|
||||||
|
serial text,
|
||||||
|
model text,
|
||||||
|
ps1_type text,
|
||||||
|
ps2_type text,
|
||||||
|
ps1_status text,
|
||||||
|
ps2_status text,
|
||||||
|
fan text,
|
||||||
|
slots integer,
|
||||||
|
vendor text,
|
||||||
|
os text,
|
||||||
|
os_ver text,
|
||||||
|
log text,
|
||||||
|
snmp_ver integer,
|
||||||
|
snmp_comm text,
|
||||||
|
snmp_class text,
|
||||||
|
vtp_domain text,
|
||||||
|
last_discover TIMESTAMP,
|
||||||
|
last_macsuck TIMESTAMP,
|
||||||
|
last_arpnip TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
-- Indexing for speed-ups
|
||||||
-- Table: device.
|
CREATE INDEX idx_device_dns ON device(dns);
|
||||||
--
|
CREATE INDEX idx_device_layers ON device(layers);
|
||||||
CREATE TABLE "device" (
|
CREATE INDEX idx_device_vendor ON device(vendor);
|
||||||
"ip" inet NOT NULL,
|
CREATE INDEX idx_device_model ON device(model);
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"dns" text,
|
CREATE TABLE device_ip (
|
||||||
"description" text,
|
ip inet,
|
||||||
"uptime" bigint,
|
alias inet,
|
||||||
"contact" text,
|
subnet cidr,
|
||||||
"name" text,
|
port text,
|
||||||
"location" text,
|
dns text,
|
||||||
"layers" character varying(8),
|
creation TIMESTAMP DEFAULT now(),
|
||||||
"ports" integer,
|
PRIMARY KEY(ip,alias)
|
||||||
"mac" macaddr,
|
|
||||||
"serial" text,
|
|
||||||
"model" text,
|
|
||||||
"ps1_type" text,
|
|
||||||
"ps2_type" text,
|
|
||||||
"ps1_status" text,
|
|
||||||
"ps2_status" text,
|
|
||||||
"fan" text,
|
|
||||||
"slots" integer,
|
|
||||||
"vendor" text,
|
|
||||||
"os" text,
|
|
||||||
"os_ver" text,
|
|
||||||
"log" text,
|
|
||||||
"snmp_ver" integer,
|
|
||||||
"snmp_comm" text,
|
|
||||||
"snmp_class" text,
|
|
||||||
"vtp_domain" text,
|
|
||||||
"last_discover" timestamp,
|
|
||||||
"last_macsuck" timestamp,
|
|
||||||
"last_arpnip" timestamp,
|
|
||||||
PRIMARY KEY ("ip")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
-- Indexing for speed ups
|
||||||
-- Table: device_module.
|
CREATE INDEX idx_device_ip_ip ON device_ip(ip);
|
||||||
--
|
CREATE INDEX idx_device_ip_alias ON device_ip(alias);
|
||||||
CREATE TABLE "device_module" (
|
CREATE INDEX idx_device_ip_ip_port ON device_ip(ip,port);
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"index" integer NOT NULL,
|
CREATE TABLE device_module (
|
||||||
"description" text,
|
ip inet not null,
|
||||||
"type" text,
|
index integer,
|
||||||
"parent" integer,
|
description text,
|
||||||
"name" text,
|
type text,
|
||||||
"class" text,
|
parent integer,
|
||||||
"pos" integer,
|
name text,
|
||||||
"hw_ver" text,
|
class text,
|
||||||
"fw_ver" text,
|
pos integer,
|
||||||
"sw_ver" text,
|
hw_ver text,
|
||||||
"serial" text,
|
fw_ver text,
|
||||||
"model" text,
|
sw_ver text,
|
||||||
"fru" boolean,
|
serial text,
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
model text,
|
||||||
"last_discover" timestamp,
|
fru boolean,
|
||||||
PRIMARY KEY ("ip", "index")
|
creation TIMESTAMP DEFAULT now(),
|
||||||
|
last_discover TIMESTAMP,
|
||||||
|
PRIMARY KEY(ip,index)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE device_port (
|
||||||
|
ip inet,
|
||||||
|
port text,
|
||||||
|
creation TIMESTAMP DEFAULT now(),
|
||||||
|
descr text,
|
||||||
|
up text,
|
||||||
|
up_admin text,
|
||||||
|
type text,
|
||||||
|
duplex text,
|
||||||
|
duplex_admin text,
|
||||||
|
speed text,
|
||||||
|
name text,
|
||||||
|
mac macaddr,
|
||||||
|
mtu integer,
|
||||||
|
stp text,
|
||||||
|
remote_ip inet,
|
||||||
|
remote_port text,
|
||||||
|
remote_type text,
|
||||||
|
remote_id text,
|
||||||
|
vlan text,
|
||||||
|
pvid integer,
|
||||||
|
lastchange bigint,
|
||||||
|
PRIMARY KEY(port,ip)
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
CREATE INDEX idx_device_port_ip ON device_port(ip);
|
||||||
-- Table: device_port_log.
|
CREATE INDEX idx_device_port_remote_ip ON device_port(remote_ip);
|
||||||
--
|
-- For the duplex mismatch finder :
|
||||||
CREATE TABLE "device_port_log" (
|
CREATE INDEX idx_device_port_ip_port_duplex ON device_port(ip,port,duplex);
|
||||||
"id" serial NOT NULL,
|
CREATE INDEX idx_device_port_ip_up_admin ON device_port(ip,up_admin);
|
||||||
"ip" inet,
|
CREATE INDEX idx_device_port_mac ON device_port(mac);
|
||||||
"port" text,
|
|
||||||
"reason" text,
|
CREATE TABLE device_port_log (
|
||||||
"log" text,
|
id serial,
|
||||||
"username" text,
|
ip inet,
|
||||||
"userip" inet,
|
port text,
|
||||||
"action" text,
|
reason text,
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
log text,
|
||||||
|
username text,
|
||||||
|
userip inet,
|
||||||
|
action text,
|
||||||
|
creation TIMESTAMP DEFAULT now()
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_device_port_log_1 ON device_port_log(ip,port);
|
||||||
|
CREATE INDEX idx_device_port_log_user ON device_port_log(username);
|
||||||
|
|
||||||
|
CREATE TABLE device_port_power (
|
||||||
|
ip inet,
|
||||||
|
port text,
|
||||||
|
module integer,
|
||||||
|
admin text,
|
||||||
|
status text,
|
||||||
|
class text,
|
||||||
|
power integer,
|
||||||
|
PRIMARY KEY(port,ip)
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
CREATE TABLE device_port_ssid (
|
||||||
-- Table: device_port_power.
|
ip inet,
|
||||||
--
|
port text,
|
||||||
CREATE TABLE "device_port_power" (
|
ssid text,
|
||||||
"ip" inet NOT NULL,
|
broadcast boolean,
|
||||||
"port" text NOT NULL,
|
bssid macaddr
|
||||||
"module" integer,
|
|
||||||
"admin" text,
|
|
||||||
"status" text,
|
|
||||||
"class" text,
|
|
||||||
"power" integer,
|
|
||||||
PRIMARY KEY ("port", "ip")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
CREATE INDEX idx_device_port_ssid_ip_port ON device_port_ssid(ip,port);
|
||||||
-- Table: device_port_ssid.
|
|
||||||
--
|
CREATE TABLE device_port_vlan (
|
||||||
CREATE TABLE "device_port_ssid" (
|
ip inet,
|
||||||
"ip" inet,
|
port text,
|
||||||
"port" text,
|
vlan integer,
|
||||||
"ssid" text,
|
native boolean not null default false,
|
||||||
"broadcast" boolean
|
creation TIMESTAMP DEFAULT now(),
|
||||||
|
last_discover TIMESTAMP DEFAULT now(),
|
||||||
|
vlantype text,
|
||||||
|
PRIMARY KEY(ip,port,vlan)
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
CREATE TABLE device_port_wireless (
|
||||||
-- Table: device_port_wireless.
|
ip inet,
|
||||||
--
|
port text,
|
||||||
CREATE TABLE "device_port_wireless" (
|
channel integer,
|
||||||
"ip" inet,
|
power integer
|
||||||
"port" text,
|
|
||||||
"channel" integer,
|
|
||||||
"power" integer
|
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
CREATE INDEX idx_device_port_wireless_ip_port ON device_port_wireless(ip,port);
|
||||||
-- Table: device_power.
|
|
||||||
--
|
CREATE TABLE device_power (
|
||||||
CREATE TABLE "device_power" (
|
ip inet,
|
||||||
"ip" inet NOT NULL,
|
module integer,
|
||||||
"module" integer NOT NULL,
|
power integer,
|
||||||
"power" integer,
|
status text,
|
||||||
"status" text,
|
PRIMARY KEY(ip,module)
|
||||||
PRIMARY KEY ("ip", "module")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
CREATE TABLE device_vlan (
|
||||||
-- Table: device_route.
|
ip inet,
|
||||||
--
|
vlan integer,
|
||||||
CREATE TABLE "device_route" (
|
description text,
|
||||||
"ip" inet NOT NULL,
|
creation TIMESTAMP DEFAULT now(),
|
||||||
"network" cidr NOT NULL,
|
last_discover TIMESTAMP DEFAULT now(),
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
PRIMARY KEY(ip,vlan)
|
||||||
"dest" inet NOT NULL,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "network", "dest")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: log.
|
CREATE TABLE log (
|
||||||
--
|
id serial,
|
||||||
CREATE TABLE "log" (
|
creation TIMESTAMP DEFAULT now(),
|
||||||
"id" serial NOT NULL,
|
class text,
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
entry text,
|
||||||
"class" text,
|
logfile text
|
||||||
"entry" text,
|
|
||||||
"logfile" text
|
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
CREATE TABLE node (
|
||||||
-- Table: node_ip.
|
mac macaddr,
|
||||||
--
|
switch inet,
|
||||||
CREATE TABLE "node_ip" (
|
port text,
|
||||||
"mac" macaddr NOT NULL,
|
vlan text default '0',
|
||||||
"ip" inet NOT NULL,
|
active boolean,
|
||||||
"active" boolean,
|
oui varchar(8),
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
time_first timestamp default now(),
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
time_recent timestamp default now(),
|
||||||
PRIMARY KEY ("mac", "ip")
|
time_last timestamp default now(),
|
||||||
|
PRIMARY KEY(mac,switch,port,vlan)
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
-- Indexes speed things up a LOT
|
||||||
-- Table: node_monitor.
|
CREATE INDEX idx_node_switch_port_active ON node(switch,port,active);
|
||||||
--
|
CREATE INDEX idx_node_switch_port ON node(switch,port);
|
||||||
CREATE TABLE "node_monitor" (
|
CREATE INDEX idx_node_switch ON node(switch);
|
||||||
"mac" macaddr NOT NULL,
|
CREATE INDEX idx_node_mac ON node(mac);
|
||||||
"active" boolean,
|
CREATE INDEX idx_node_mac_active ON node(mac,active);
|
||||||
"why" text,
|
-- CREATE INDEX idx_node_oui ON node(oui);
|
||||||
"cc" text,
|
|
||||||
"date" timestamp DEFAULT current_timestamp,
|
CREATE TABLE node_ip (
|
||||||
PRIMARY KEY ("mac")
|
mac macaddr,
|
||||||
|
ip inet,
|
||||||
|
active boolean,
|
||||||
|
time_first timestamp default now(),
|
||||||
|
time_last timestamp default now(),
|
||||||
|
PRIMARY KEY(mac,ip)
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
-- Indexing speed ups.
|
||||||
-- Table: node_nbt.
|
CREATE INDEX idx_node_ip_ip ON node_ip(ip);
|
||||||
--
|
CREATE INDEX idx_node_ip_ip_active ON node_ip(ip,active);
|
||||||
CREATE TABLE "node_nbt" (
|
CREATE INDEX idx_node_ip_mac ON node_ip(mac);
|
||||||
"mac" macaddr NOT NULL,
|
CREATE INDEX idx_node_ip_mac_active ON node_ip(mac,active);
|
||||||
"ip" inet,
|
|
||||||
"nbname" text,
|
CREATE TABLE node_monitor (
|
||||||
"domain" text,
|
mac macaddr,
|
||||||
"server" boolean,
|
active boolean,
|
||||||
"nbuser" text,
|
why text,
|
||||||
"active" boolean,
|
cc text,
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
date TIMESTAMP DEFAULT now(),
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
PRIMARY KEY(mac)
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
-- node_nbt - Hold Netbios information for each node.
|
||||||
-- Table: node_wireless.
|
|
||||||
--
|
CREATE TABLE node_nbt (
|
||||||
CREATE TABLE "node_wireless" (
|
mac macaddr PRIMARY KEY,
|
||||||
"mac" macaddr NOT NULL,
|
ip inet,
|
||||||
"uptime" integer,
|
nbname text,
|
||||||
"maxrate" integer,
|
domain text,
|
||||||
"txrate" integer,
|
server boolean,
|
||||||
"sigstrength" integer,
|
nbuser text,
|
||||||
"sigqual" integer,
|
active boolean,
|
||||||
"rxpkt" integer,
|
time_first timestamp default now(),
|
||||||
"txpkt" integer,
|
time_last timestamp default now()
|
||||||
"rxbyte" bigint,
|
|
||||||
"txbyte" bigint,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
-- Indexing speed ups.
|
||||||
-- Table: oui.
|
CREATE INDEX idx_node_nbt_mac ON node_nbt(mac);
|
||||||
--
|
CREATE INDEX idx_node_nbt_nbname ON node_nbt(nbname);
|
||||||
CREATE TABLE "oui" (
|
CREATE INDEX idx_node_nbt_domain ON node_nbt(domain);
|
||||||
"oui" character varying(8) NOT NULL,
|
CREATE INDEX idx_node_nbt_mac_active ON node_nbt(mac,active);
|
||||||
"company" text,
|
|
||||||
PRIMARY KEY ("oui")
|
-- Add "vlan" column to node table
|
||||||
|
-- ALTER TABLE node ADD COLUMN vlan text default '0';
|
||||||
|
|
||||||
|
alter table node drop constraint node_pkey;
|
||||||
|
alter table node add primary key (mac, switch, port, vlan);
|
||||||
|
|
||||||
|
CREATE TABLE node_wireless (
|
||||||
|
mac macaddr,
|
||||||
|
ssid text default '',
|
||||||
|
uptime integer,
|
||||||
|
maxrate integer,
|
||||||
|
txrate integer,
|
||||||
|
sigstrength integer,
|
||||||
|
sigqual integer,
|
||||||
|
rxpkt integer,
|
||||||
|
txpkt integer,
|
||||||
|
rxbyte bigint,
|
||||||
|
txbyte bigint,
|
||||||
|
time_last timestamp default now(),
|
||||||
|
PRIMARY KEY(mac,ssid)
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: process.
|
-- Add "ssid" column to node_wireless table
|
||||||
--
|
-- ALTER TABLE node_wireless ADD ssid text default '';
|
||||||
CREATE TABLE "process" (
|
|
||||||
"controller" integer NOT NULL,
|
alter table node_wireless drop constraint node_wireless_pkey;
|
||||||
"device" inet NOT NULL,
|
alter table node_wireless add primary key (mac, ssid);
|
||||||
"action" text NOT NULL,
|
|
||||||
"status" text,
|
|
||||||
"count" integer,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
CREATE TABLE oui (
|
||||||
|
oui varchar(8) PRIMARY KEY,
|
||||||
|
company text
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: sessions.
|
-- process table - Queue to coordinate between processes in multi-process mode.
|
||||||
--
|
|
||||||
CREATE TABLE "sessions" (
|
CREATE TABLE process (
|
||||||
"id" character(32) NOT NULL,
|
controller integer not null,
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
device inet not null,
|
||||||
"a_session" text,
|
action text not null,
|
||||||
PRIMARY KEY ("id")
|
status text,
|
||||||
|
count integer,
|
||||||
|
creation TIMESTAMP DEFAULT now()
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE sessions (
|
||||||
|
id char(32) NOT NULL PRIMARY KEY,
|
||||||
|
creation TIMESTAMP DEFAULT now(),
|
||||||
|
a_session text
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE subnets (
|
||||||
|
net cidr NOT NULL,
|
||||||
|
creation timestamp default now(),
|
||||||
|
last_discover timestamp default now(),
|
||||||
|
PRIMARY KEY(net)
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
-- Add "topology" table to augment manual topo file
|
||||||
-- Table: subnets.
|
CREATE TABLE topology (
|
||||||
--
|
dev1 inet not null,
|
||||||
CREATE TABLE "subnets" (
|
port1 text not null,
|
||||||
"net" cidr NOT NULL,
|
dev2 inet not null,
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
port2 text not null
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("net")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: user_log.
|
|
||||||
--
|
|
||||||
CREATE TABLE "user_log" (
|
|
||||||
"entry" serial NOT NULL,
|
|
||||||
"username" character varying(50),
|
|
||||||
"userip" inet,
|
|
||||||
"event" text,
|
|
||||||
"details" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: users.
|
|
||||||
--
|
|
||||||
CREATE TABLE "users" (
|
|
||||||
"username" character varying(50) NOT NULL,
|
|
||||||
"password" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_on" timestamp,
|
|
||||||
"port_control" boolean DEFAULT false,
|
|
||||||
"ldap" boolean DEFAULT false,
|
|
||||||
"admin" boolean DEFAULT false,
|
|
||||||
"fullname" text,
|
|
||||||
"note" text,
|
|
||||||
PRIMARY KEY ("username")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
-- This table logs login and logout / change requests for users
|
||||||
-- Table: device_vlan.
|
|
||||||
--
|
|
||||||
CREATE TABLE "device_vlan" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"vlan" integer NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_vlan_idx_ip" on "device_vlan" ("ip");
|
|
||||||
|
|
||||||
--
|
CREATE TABLE user_log (
|
||||||
-- Table: device_ip.
|
entry serial,
|
||||||
--
|
username varchar(50),
|
||||||
CREATE TABLE "device_ip" (
|
userip inet,
|
||||||
"ip" inet NOT NULL,
|
event text,
|
||||||
"alias" inet NOT NULL,
|
details text,
|
||||||
"subnet" cidr,
|
creation TIMESTAMP DEFAULT now()
|
||||||
"port" text,
|
);
|
||||||
"dns" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "alias"),
|
|
||||||
CONSTRAINT "device_ip_alias" UNIQUE ("alias")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_ip_idx_ip" on "device_ip" ("ip");
|
|
||||||
CREATE INDEX "device_ip_idx_ip_port" on "device_ip" ("ip", "port");
|
|
||||||
|
|
||||||
--
|
CREATE TABLE users (
|
||||||
-- Table: device_port.
|
username varchar(50) PRIMARY KEY,
|
||||||
--
|
password text,
|
||||||
CREATE TABLE "device_port" (
|
creation TIMESTAMP DEFAULT now(),
|
||||||
"ip" inet NOT NULL,
|
last_on TIMESTAMP,
|
||||||
"port" text NOT NULL,
|
port_control boolean DEFAULT false,
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
ldap boolean DEFAULT false,
|
||||||
"descr" text,
|
admin boolean DEFAULT false,
|
||||||
"up" text,
|
fullname text,
|
||||||
"up_admin" text,
|
note text
|
||||||
"type" text,
|
);
|
||||||
"duplex" text,
|
|
||||||
"duplex_admin" text,
|
|
||||||
"speed" text,
|
|
||||||
"name" text,
|
|
||||||
"mac" macaddr,
|
|
||||||
"mtu" integer,
|
|
||||||
"stp" text,
|
|
||||||
"remote_ip" inet,
|
|
||||||
"remote_port" text,
|
|
||||||
"remote_type" text,
|
|
||||||
"remote_id" text,
|
|
||||||
"vlan" text,
|
|
||||||
"pvid" integer,
|
|
||||||
"lastchange" bigint,
|
|
||||||
PRIMARY KEY ("port", "ip")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_idx_ip" on "device_port" ("ip");
|
|
||||||
CREATE INDEX "device_port_idx_remote_ip" on "device_port" ("remote_ip");
|
|
||||||
|
|
||||||
--
|
COMMIT;
|
||||||
-- Table: device_port_vlan.
|
|
||||||
--
|
|
||||||
CREATE TABLE "device_port_vlan" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"vlan" integer NOT NULL,
|
|
||||||
"native" boolean DEFAULT false NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "port", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip" on "device_port_vlan" ("ip");
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip_port" on "device_port_vlan" ("ip", "port");
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip_vlan" on "device_port_vlan" ("ip", "vlan");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node.
|
|
||||||
--
|
|
||||||
CREATE TABLE "node" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"switch" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"oui" character varying(8),
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_recent" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac", "switch", "port")
|
|
||||||
);
|
|
||||||
CREATE INDEX "node_idx_switch" on "node" ("switch");
|
|
||||||
CREATE INDEX "node_idx_switch_port" on "node" ("switch", "port");
|
|
||||||
CREATE INDEX "node_idx_oui" on "node" ("oui");
|
|
||||||
|
|
||||||
-- Not used in Netdisco, because they upset the legacy netdisco.pm code
|
|
||||||
--
|
|
||||||
-- --
|
|
||||||
-- -- Foreign Key Definitions
|
|
||||||
-- --
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_vlan" ADD CONSTRAINT "device_vlan_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_ip" ADD CONSTRAINT "device_ip_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_ip" ADD CONSTRAINT "device_ip_fk_ip_port" FOREIGN KEY ("ip", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port" ADD CONSTRAINT "device_port_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port" ADD CONSTRAINT "device_port_fk_remote_ip" FOREIGN KEY ("remote_ip")
|
|
||||||
-- REFERENCES "device_ip" ("alias") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD CONSTRAINT "device_port_vlan_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD CONSTRAINT "device_port_vlan_fk_ip_port" FOREIGN KEY ("ip", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD CONSTRAINT "device_port_vlan_fk_ip_vlan" FOREIGN KEY ("ip", "vlan")
|
|
||||||
-- REFERENCES "device_vlan" ("ip", "vlan") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD CONSTRAINT "node_fk_switch" FOREIGN KEY ("switch")
|
|
||||||
-- REFERENCES "device" ("ip") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD CONSTRAINT "node_fk_switch_port" FOREIGN KEY ("switch", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD CONSTRAINT "node_fk_oui" FOREIGN KEY ("oui")
|
|
||||||
-- REFERENCES "oui" ("oui") DEFERRABLE;
|
|
||||||
--
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
--
|
|
||||||
-- Created by SQL::Translator::Producer::PostgreSQL
|
|
||||||
-- Created on Wed Oct 10 14:24:20 2012
|
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
-- Convert schema '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-3-PostgreSQL.sql' to '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-4-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE node ADD COLUMN vlan text DEFAULT '0' NOT NULL;
|
ALTER TABLE device_port_vlan ADD COLUMN vlantype text;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
-- Convert schema '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-3-PostgreSQL.sql' to '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-4-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE node_wireless ADD COLUMN ssid text DEFAULT '' NOT NULL;
|
ALTER TABLE node_ip ADD COLUMN dns text;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
-- Convert schema '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-3-PostgreSQL.sql' to '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-4-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
CREATE INDEX device_port_power_idx_ip_port on device_port_power (ip, port);
|
ALTER TABLE node DROP CONSTRAINT node_pkey;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
-- Convert schema '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-3-PostgreSQL.sql' to '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-4-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE admin ADD PRIMARY KEY (job);
|
ALTER TABLE node_wireless DROP CONSTRAINT node_wireless_pkey;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
-- Convert schema '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-3-PostgreSQL.sql' to '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-4-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE node ADD PRIMARY KEY (mac, switch, port, vlan);
|
ALTER TABLE node ADD COLUMN vlan text DEFAULT '0' NOT NULL;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
-- Convert schema '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-3-PostgreSQL.sql' to '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-4-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE node_wireless ADD PRIMARY KEY (mac, ssid);
|
ALTER TABLE node_wireless ADD COLUMN ssid text DEFAULT '' NOT NULL;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
CREATE UNIQUE INDEX jobs_queued ON admin (
|
CREATE INDEX device_port_power_idx_ip_port on device_port_power (ip, port);
|
||||||
action,
|
|
||||||
coalesce(subaction, '_x_'),
|
|
||||||
coalesce(device, '255.255.255.255'),
|
|
||||||
coalesce(port, '_x_')
|
|
||||||
) WHERE status LIKE 'queued%';
|
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,469 +0,0 @@
|
|||||||
--
|
|
||||||
-- Created by SQL::Translator::Producer::PostgreSQL
|
|
||||||
-- Created on Tue Jan 29 22:24:59 2013
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Table: admin
|
|
||||||
--
|
|
||||||
DROP TABLE "admin" CASCADE;
|
|
||||||
CREATE TABLE "admin" (
|
|
||||||
"job" serial NOT NULL,
|
|
||||||
"entered" timestamp DEFAULT current_timestamp,
|
|
||||||
"started" timestamp,
|
|
||||||
"finished" timestamp,
|
|
||||||
"device" inet,
|
|
||||||
"port" text,
|
|
||||||
"action" text,
|
|
||||||
"subaction" text,
|
|
||||||
"status" text,
|
|
||||||
"username" text,
|
|
||||||
"userip" inet,
|
|
||||||
"log" text,
|
|
||||||
"debug" boolean,
|
|
||||||
PRIMARY KEY ("job")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device
|
|
||||||
--
|
|
||||||
DROP TABLE "device" CASCADE;
|
|
||||||
CREATE TABLE "device" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"dns" text,
|
|
||||||
"description" text,
|
|
||||||
"uptime" bigint,
|
|
||||||
"contact" text,
|
|
||||||
"name" text,
|
|
||||||
"location" text,
|
|
||||||
"layers" character varying(8),
|
|
||||||
"ports" integer,
|
|
||||||
"mac" macaddr,
|
|
||||||
"serial" text,
|
|
||||||
"model" text,
|
|
||||||
"ps1_type" text,
|
|
||||||
"ps2_type" text,
|
|
||||||
"ps1_status" text,
|
|
||||||
"ps2_status" text,
|
|
||||||
"fan" text,
|
|
||||||
"slots" integer,
|
|
||||||
"vendor" text,
|
|
||||||
"os" text,
|
|
||||||
"os_ver" text,
|
|
||||||
"log" text,
|
|
||||||
"snmp_ver" integer,
|
|
||||||
"snmp_comm" text,
|
|
||||||
"snmp_class" text,
|
|
||||||
"vtp_domain" text,
|
|
||||||
"last_discover" timestamp,
|
|
||||||
"last_macsuck" timestamp,
|
|
||||||
"last_arpnip" timestamp,
|
|
||||||
PRIMARY KEY ("ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_module
|
|
||||||
--
|
|
||||||
DROP TABLE "device_module" CASCADE;
|
|
||||||
CREATE TABLE "device_module" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"index" integer NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"type" text,
|
|
||||||
"parent" integer,
|
|
||||||
"name" text,
|
|
||||||
"class" text,
|
|
||||||
"pos" integer,
|
|
||||||
"hw_ver" text,
|
|
||||||
"fw_ver" text,
|
|
||||||
"sw_ver" text,
|
|
||||||
"serial" text,
|
|
||||||
"model" text,
|
|
||||||
"fru" boolean,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp,
|
|
||||||
PRIMARY KEY ("ip", "index")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_log
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_log" CASCADE;
|
|
||||||
CREATE TABLE "device_port_log" (
|
|
||||||
"id" serial NOT NULL,
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"reason" text,
|
|
||||||
"log" text,
|
|
||||||
"username" text,
|
|
||||||
"userip" inet,
|
|
||||||
"action" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_ssid
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_ssid" CASCADE;
|
|
||||||
CREATE TABLE "device_port_ssid" (
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"ssid" text,
|
|
||||||
"broadcast" boolean,
|
|
||||||
"bssid" macaddr
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_wireless
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_wireless" CASCADE;
|
|
||||||
CREATE TABLE "device_port_wireless" (
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"channel" integer,
|
|
||||||
"power" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_power
|
|
||||||
--
|
|
||||||
DROP TABLE "device_power" CASCADE;
|
|
||||||
CREATE TABLE "device_power" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"module" integer NOT NULL,
|
|
||||||
"power" integer,
|
|
||||||
"status" text,
|
|
||||||
PRIMARY KEY ("ip", "module")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_route
|
|
||||||
--
|
|
||||||
DROP TABLE "device_route" CASCADE;
|
|
||||||
CREATE TABLE "device_route" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"network" cidr NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"dest" inet NOT NULL,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "network", "dest")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: log
|
|
||||||
--
|
|
||||||
DROP TABLE "log" CASCADE;
|
|
||||||
CREATE TABLE "log" (
|
|
||||||
"id" serial NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"class" text,
|
|
||||||
"entry" text,
|
|
||||||
"logfile" text
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_ip
|
|
||||||
--
|
|
||||||
DROP TABLE "node_ip" CASCADE;
|
|
||||||
CREATE TABLE "node_ip" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"dns" text,
|
|
||||||
"active" boolean,
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac", "ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_monitor
|
|
||||||
--
|
|
||||||
DROP TABLE "node_monitor" CASCADE;
|
|
||||||
CREATE TABLE "node_monitor" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"why" text,
|
|
||||||
"cc" text,
|
|
||||||
"date" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_nbt
|
|
||||||
--
|
|
||||||
DROP TABLE "node_nbt" CASCADE;
|
|
||||||
CREATE TABLE "node_nbt" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"ip" inet,
|
|
||||||
"nbname" text,
|
|
||||||
"domain" text,
|
|
||||||
"server" boolean,
|
|
||||||
"nbuser" text,
|
|
||||||
"active" boolean,
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_wireless
|
|
||||||
--
|
|
||||||
DROP TABLE "node_wireless" CASCADE;
|
|
||||||
CREATE TABLE "node_wireless" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"uptime" integer,
|
|
||||||
"maxrate" integer,
|
|
||||||
"txrate" integer,
|
|
||||||
"sigstrength" integer,
|
|
||||||
"sigqual" integer,
|
|
||||||
"rxpkt" integer,
|
|
||||||
"txpkt" integer,
|
|
||||||
"rxbyte" bigint,
|
|
||||||
"txbyte" bigint,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
"ssid" text DEFAULT '' NOT NULL,
|
|
||||||
PRIMARY KEY ("mac", "ssid")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: oui
|
|
||||||
--
|
|
||||||
DROP TABLE "oui" CASCADE;
|
|
||||||
CREATE TABLE "oui" (
|
|
||||||
"oui" character varying(8) NOT NULL,
|
|
||||||
"company" text,
|
|
||||||
PRIMARY KEY ("oui")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: process
|
|
||||||
--
|
|
||||||
DROP TABLE "process" CASCADE;
|
|
||||||
CREATE TABLE "process" (
|
|
||||||
"controller" integer NOT NULL,
|
|
||||||
"device" inet NOT NULL,
|
|
||||||
"action" text NOT NULL,
|
|
||||||
"status" text,
|
|
||||||
"count" integer,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: sessions
|
|
||||||
--
|
|
||||||
DROP TABLE "sessions" CASCADE;
|
|
||||||
CREATE TABLE "sessions" (
|
|
||||||
"id" character(32) NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"a_session" text,
|
|
||||||
PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: subnets
|
|
||||||
--
|
|
||||||
DROP TABLE "subnets" CASCADE;
|
|
||||||
CREATE TABLE "subnets" (
|
|
||||||
"net" cidr NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("net")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: topology
|
|
||||||
--
|
|
||||||
DROP TABLE "topology" CASCADE;
|
|
||||||
CREATE TABLE "topology" (
|
|
||||||
"dev1" inet NOT NULL,
|
|
||||||
"port1" text NOT NULL,
|
|
||||||
"dev2" inet NOT NULL,
|
|
||||||
"port2" text NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: user_log
|
|
||||||
--
|
|
||||||
DROP TABLE "user_log" CASCADE;
|
|
||||||
CREATE TABLE "user_log" (
|
|
||||||
"entry" serial NOT NULL,
|
|
||||||
"username" character varying(50),
|
|
||||||
"userip" inet,
|
|
||||||
"event" text,
|
|
||||||
"details" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: users
|
|
||||||
--
|
|
||||||
DROP TABLE "users" CASCADE;
|
|
||||||
CREATE TABLE "users" (
|
|
||||||
"username" character varying(50) NOT NULL,
|
|
||||||
"password" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_on" timestamp,
|
|
||||||
"port_control" boolean DEFAULT false,
|
|
||||||
"ldap" boolean DEFAULT false,
|
|
||||||
"admin" boolean DEFAULT false,
|
|
||||||
"fullname" text,
|
|
||||||
"note" text,
|
|
||||||
PRIMARY KEY ("username")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_vlan
|
|
||||||
--
|
|
||||||
DROP TABLE "device_vlan" CASCADE;
|
|
||||||
CREATE TABLE "device_vlan" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"vlan" integer NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_vlan_idx_ip" on "device_vlan" ("ip");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_ip
|
|
||||||
--
|
|
||||||
DROP TABLE "device_ip" CASCADE;
|
|
||||||
CREATE TABLE "device_ip" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"alias" inet NOT NULL,
|
|
||||||
"subnet" cidr,
|
|
||||||
"port" text,
|
|
||||||
"dns" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "alias"),
|
|
||||||
CONSTRAINT "device_ip_alias" UNIQUE ("alias")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_ip_idx_ip" on "device_ip" ("ip");
|
|
||||||
CREATE INDEX "device_ip_idx_ip_port" on "device_ip" ("ip", "port");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port" CASCADE;
|
|
||||||
CREATE TABLE "device_port" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"descr" text,
|
|
||||||
"up" text,
|
|
||||||
"up_admin" text,
|
|
||||||
"type" text,
|
|
||||||
"duplex" text,
|
|
||||||
"duplex_admin" text,
|
|
||||||
"speed" text,
|
|
||||||
"name" text,
|
|
||||||
"mac" macaddr,
|
|
||||||
"mtu" integer,
|
|
||||||
"stp" text,
|
|
||||||
"remote_ip" inet,
|
|
||||||
"remote_port" text,
|
|
||||||
"remote_type" text,
|
|
||||||
"remote_id" text,
|
|
||||||
"vlan" text,
|
|
||||||
"pvid" integer,
|
|
||||||
"lastchange" bigint,
|
|
||||||
PRIMARY KEY ("port", "ip")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_idx_ip" on "device_port" ("ip");
|
|
||||||
CREATE INDEX "device_port_idx_remote_ip" on "device_port" ("remote_ip");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_power
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_power" CASCADE;
|
|
||||||
CREATE TABLE "device_port_power" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"module" integer,
|
|
||||||
"admin" text,
|
|
||||||
"status" text,
|
|
||||||
"class" text,
|
|
||||||
"power" integer,
|
|
||||||
PRIMARY KEY ("port", "ip")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_power_idx_ip_port" on "device_port_power" ("ip", "port");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_vlan
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_vlan" CASCADE;
|
|
||||||
CREATE TABLE "device_port_vlan" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"vlan" integer NOT NULL,
|
|
||||||
"native" boolean DEFAULT false NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
"vlantype" text,
|
|
||||||
PRIMARY KEY ("ip", "port", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip" on "device_port_vlan" ("ip");
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip_port" on "device_port_vlan" ("ip", "port");
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip_vlan" on "device_port_vlan" ("ip", "vlan");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node
|
|
||||||
--
|
|
||||||
DROP TABLE "node" CASCADE;
|
|
||||||
CREATE TABLE "node" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"switch" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"oui" character varying(8),
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_recent" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
"vlan" text DEFAULT '0' NOT NULL,
|
|
||||||
PRIMARY KEY ("mac", "switch", "port", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "node_idx_switch" on "node" ("switch");
|
|
||||||
CREATE INDEX "node_idx_switch_port" on "node" ("switch", "port");
|
|
||||||
CREATE INDEX "node_idx_oui" on "node" ("oui");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Foreign Key Definitions
|
|
||||||
--
|
|
||||||
|
|
||||||
-- ALTER TABLE "device_vlan" ADD FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_ip" ADD FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_ip" ADD FOREIGN KEY ("ip", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port" ADD FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port" ADD FOREIGN KEY ("remote_ip")
|
|
||||||
-- REFERENCES "device_ip" ("alias") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_power" ADD FOREIGN KEY ("ip", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") ON DELETE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD FOREIGN KEY ("ip", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD FOREIGN KEY ("ip", "vlan")
|
|
||||||
-- REFERENCES "device_vlan" ("ip", "vlan") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD FOREIGN KEY ("switch")
|
|
||||||
-- REFERENCES "device" ("ip") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD FOREIGN KEY ("switch", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD FOREIGN KEY ("oui")
|
|
||||||
-- REFERENCES "oui" ("oui") DEFERRABLE;
|
|
||||||
--
|
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
-- Convert schema '/home/devver/netdisco-ng/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-17-PostgreSQL.sql' to '/home/devver/netdisco-ng/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-18-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE topology ADD CONSTRAINT topology_dev1_port1 UNIQUE (dev1, port1);
|
ALTER TABLE admin ADD PRIMARY KEY (job);
|
||||||
|
|
||||||
ALTER TABLE topology ADD CONSTRAINT topology_dev2_port2 UNIQUE (dev2, port2);
|
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,436 +0,0 @@
|
|||||||
--
|
|
||||||
-- Created by SQL::Translator::Producer::PostgreSQL
|
|
||||||
-- Created on Sun Mar 24 18:45:08 2013
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Table: admin.
|
|
||||||
--
|
|
||||||
DROP TABLE "admin" CASCADE;
|
|
||||||
CREATE TABLE "admin" (
|
|
||||||
"job" serial NOT NULL,
|
|
||||||
"entered" timestamp DEFAULT current_timestamp,
|
|
||||||
"started" timestamp,
|
|
||||||
"finished" timestamp,
|
|
||||||
"device" inet,
|
|
||||||
"port" text,
|
|
||||||
"action" text,
|
|
||||||
"subaction" text,
|
|
||||||
"status" text,
|
|
||||||
"username" text,
|
|
||||||
"userip" inet,
|
|
||||||
"log" text,
|
|
||||||
"debug" boolean,
|
|
||||||
PRIMARY KEY ("job"),
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX jobs_queued ON admin (
|
|
||||||
action,
|
|
||||||
coalesce(subaction, '_x_'),
|
|
||||||
coalesce(device, '255.255.255.255'),
|
|
||||||
coalesce(port, '_x_')
|
|
||||||
) WHERE status LIKE 'queued%';
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device.
|
|
||||||
--
|
|
||||||
DROP TABLE "device" CASCADE;
|
|
||||||
CREATE TABLE "device" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"dns" text,
|
|
||||||
"description" text,
|
|
||||||
"uptime" bigint,
|
|
||||||
"contact" text,
|
|
||||||
"name" text,
|
|
||||||
"location" text,
|
|
||||||
"layers" character varying(8),
|
|
||||||
"ports" integer,
|
|
||||||
"mac" macaddr,
|
|
||||||
"serial" text,
|
|
||||||
"model" text,
|
|
||||||
"ps1_type" text,
|
|
||||||
"ps2_type" text,
|
|
||||||
"ps1_status" text,
|
|
||||||
"ps2_status" text,
|
|
||||||
"fan" text,
|
|
||||||
"slots" integer,
|
|
||||||
"vendor" text,
|
|
||||||
"os" text,
|
|
||||||
"os_ver" text,
|
|
||||||
"log" text,
|
|
||||||
"snmp_ver" integer,
|
|
||||||
"snmp_comm" text,
|
|
||||||
"snmp_class" text,
|
|
||||||
"vtp_domain" text,
|
|
||||||
"last_discover" timestamp,
|
|
||||||
"last_macsuck" timestamp,
|
|
||||||
"last_arpnip" timestamp,
|
|
||||||
PRIMARY KEY ("ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_module.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_module" CASCADE;
|
|
||||||
CREATE TABLE "device_module" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"index" integer NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"type" text,
|
|
||||||
"parent" integer,
|
|
||||||
"name" text,
|
|
||||||
"class" text,
|
|
||||||
"pos" integer,
|
|
||||||
"hw_ver" text,
|
|
||||||
"fw_ver" text,
|
|
||||||
"sw_ver" text,
|
|
||||||
"serial" text,
|
|
||||||
"model" text,
|
|
||||||
"fru" boolean,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp,
|
|
||||||
PRIMARY KEY ("ip", "index")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_log.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_log" CASCADE;
|
|
||||||
CREATE TABLE "device_port_log" (
|
|
||||||
"id" serial NOT NULL,
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"reason" text,
|
|
||||||
"log" text,
|
|
||||||
"username" text,
|
|
||||||
"userip" inet,
|
|
||||||
"action" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_ssid.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_ssid" CASCADE;
|
|
||||||
CREATE TABLE "device_port_ssid" (
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"ssid" text,
|
|
||||||
"broadcast" boolean,
|
|
||||||
"bssid" macaddr
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_wireless.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_wireless" CASCADE;
|
|
||||||
CREATE TABLE "device_port_wireless" (
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"channel" integer,
|
|
||||||
"power" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_power.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_power" CASCADE;
|
|
||||||
CREATE TABLE "device_power" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"module" integer NOT NULL,
|
|
||||||
"power" integer,
|
|
||||||
"status" text,
|
|
||||||
PRIMARY KEY ("ip", "module")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_route.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_route" CASCADE;
|
|
||||||
CREATE TABLE "device_route" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"network" cidr NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"dest" inet NOT NULL,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "network", "dest")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: log.
|
|
||||||
--
|
|
||||||
DROP TABLE "log" CASCADE;
|
|
||||||
CREATE TABLE "log" (
|
|
||||||
"id" serial NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"class" text,
|
|
||||||
"entry" text,
|
|
||||||
"logfile" text
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_ip.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_ip" CASCADE;
|
|
||||||
CREATE TABLE "node_ip" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"dns" text,
|
|
||||||
"active" boolean,
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac", "ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_monitor.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_monitor" CASCADE;
|
|
||||||
CREATE TABLE "node_monitor" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"why" text,
|
|
||||||
"cc" text,
|
|
||||||
"date" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_nbt.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_nbt" CASCADE;
|
|
||||||
CREATE TABLE "node_nbt" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"ip" inet,
|
|
||||||
"nbname" text,
|
|
||||||
"domain" text,
|
|
||||||
"server" boolean,
|
|
||||||
"nbuser" text,
|
|
||||||
"active" boolean,
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_wireless.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_wireless" CASCADE;
|
|
||||||
CREATE TABLE "node_wireless" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"uptime" integer,
|
|
||||||
"maxrate" integer,
|
|
||||||
"txrate" integer,
|
|
||||||
"sigstrength" integer,
|
|
||||||
"sigqual" integer,
|
|
||||||
"rxpkt" integer,
|
|
||||||
"txpkt" integer,
|
|
||||||
"rxbyte" bigint,
|
|
||||||
"txbyte" bigint,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
"ssid" text DEFAULT '' NOT NULL,
|
|
||||||
PRIMARY KEY ("mac", "ssid")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: oui.
|
|
||||||
--
|
|
||||||
DROP TABLE "oui" CASCADE;
|
|
||||||
CREATE TABLE "oui" (
|
|
||||||
"oui" character varying(8) NOT NULL,
|
|
||||||
"company" text,
|
|
||||||
PRIMARY KEY ("oui")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: process.
|
|
||||||
--
|
|
||||||
DROP TABLE "process" CASCADE;
|
|
||||||
CREATE TABLE "process" (
|
|
||||||
"controller" integer NOT NULL,
|
|
||||||
"device" inet NOT NULL,
|
|
||||||
"action" text NOT NULL,
|
|
||||||
"status" text,
|
|
||||||
"count" integer,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: sessions.
|
|
||||||
--
|
|
||||||
DROP TABLE "sessions" CASCADE;
|
|
||||||
CREATE TABLE "sessions" (
|
|
||||||
"id" character(32) NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"a_session" text,
|
|
||||||
PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: subnets.
|
|
||||||
--
|
|
||||||
DROP TABLE "subnets" CASCADE;
|
|
||||||
CREATE TABLE "subnets" (
|
|
||||||
"net" cidr NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("net")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: topology.
|
|
||||||
--
|
|
||||||
DROP TABLE "topology" CASCADE;
|
|
||||||
CREATE TABLE "topology" (
|
|
||||||
"dev1" inet NOT NULL,
|
|
||||||
"port1" text NOT NULL,
|
|
||||||
"dev2" inet NOT NULL,
|
|
||||||
"port2" text NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: user_log.
|
|
||||||
--
|
|
||||||
DROP TABLE "user_log" CASCADE;
|
|
||||||
CREATE TABLE "user_log" (
|
|
||||||
"entry" serial NOT NULL,
|
|
||||||
"username" character varying(50),
|
|
||||||
"userip" inet,
|
|
||||||
"event" text,
|
|
||||||
"details" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: users.
|
|
||||||
--
|
|
||||||
DROP TABLE "users" CASCADE;
|
|
||||||
CREATE TABLE "users" (
|
|
||||||
"username" character varying(50) NOT NULL,
|
|
||||||
"password" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_on" timestamp,
|
|
||||||
"port_control" boolean DEFAULT false,
|
|
||||||
"ldap" boolean DEFAULT false,
|
|
||||||
"admin" boolean DEFAULT false,
|
|
||||||
"fullname" text,
|
|
||||||
"note" text,
|
|
||||||
PRIMARY KEY ("username")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_vlan.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_vlan" CASCADE;
|
|
||||||
CREATE TABLE "device_vlan" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"vlan" integer NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_vlan_idx_ip" on "device_vlan" ("ip");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_ip.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_ip" CASCADE;
|
|
||||||
CREATE TABLE "device_ip" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"alias" inet NOT NULL,
|
|
||||||
"subnet" cidr,
|
|
||||||
"port" text,
|
|
||||||
"dns" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "alias"),
|
|
||||||
CONSTRAINT "device_ip_alias" UNIQUE ("alias")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_ip_idx_ip" on "device_ip" ("ip");
|
|
||||||
CREATE INDEX "device_ip_idx_ip_port" on "device_ip" ("ip", "port");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port" CASCADE;
|
|
||||||
CREATE TABLE "device_port" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"descr" text,
|
|
||||||
"up" text,
|
|
||||||
"up_admin" text,
|
|
||||||
"type" text,
|
|
||||||
"duplex" text,
|
|
||||||
"duplex_admin" text,
|
|
||||||
"speed" text,
|
|
||||||
"name" text,
|
|
||||||
"mac" macaddr,
|
|
||||||
"mtu" integer,
|
|
||||||
"stp" text,
|
|
||||||
"remote_ip" inet,
|
|
||||||
"remote_port" text,
|
|
||||||
"remote_type" text,
|
|
||||||
"remote_id" text,
|
|
||||||
"vlan" text,
|
|
||||||
"pvid" integer,
|
|
||||||
"lastchange" bigint,
|
|
||||||
PRIMARY KEY ("port", "ip")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_idx_ip" on "device_port" ("ip");
|
|
||||||
CREATE INDEX "device_port_idx_remote_ip" on "device_port" ("remote_ip");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_power.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_power" CASCADE;
|
|
||||||
CREATE TABLE "device_port_power" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"module" integer,
|
|
||||||
"admin" text,
|
|
||||||
"status" text,
|
|
||||||
"class" text,
|
|
||||||
"power" integer,
|
|
||||||
PRIMARY KEY ("port", "ip")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_power_idx_ip_port" on "device_port_power" ("ip", "port");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_vlan.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_vlan" CASCADE;
|
|
||||||
CREATE TABLE "device_port_vlan" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"vlan" integer NOT NULL,
|
|
||||||
"native" boolean DEFAULT false NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
"vlantype" text,
|
|
||||||
PRIMARY KEY ("ip", "port", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip" on "device_port_vlan" ("ip");
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip_port" on "device_port_vlan" ("ip", "port");
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip_vlan" on "device_port_vlan" ("ip", "vlan");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node.
|
|
||||||
--
|
|
||||||
DROP TABLE "node" CASCADE;
|
|
||||||
CREATE TABLE "node" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"switch" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"oui" character varying(8),
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_recent" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
"vlan" text DEFAULT '0' NOT NULL,
|
|
||||||
PRIMARY KEY ("mac", "switch", "port", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "node_idx_switch" on "node" ("switch");
|
|
||||||
CREATE INDEX "node_idx_switch_port" on "node" ("switch", "port");
|
|
||||||
CREATE INDEX "node_idx_oui" on "node" ("oui");
|
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE device_port ADD COLUMN "manual_topo" bool DEFAULT false NOT NULL;
|
ALTER TABLE node ADD PRIMARY KEY (mac, switch, port, vlan);
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE device_port ADD COLUMN "is_uplink" bool;
|
ALTER TABLE node_wireless ADD PRIMARY KEY (mac, ssid);
|
||||||
ALTER TABLE device_port ADD COLUMN "is_uplink_admin" bool;
|
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
-- Convert schema '/home/sy0/git/netdisco-frontend-sandpit/Netdisco/lib/Netdisco/DB/schema_versions/Netdisco-DB-1-PostgreSQL.sql' to '/home/sy0/git/netdisco-frontend-sandpit/Netdisco/lib/Netdisco/DB/schema_versions/Netdisco-DB-2-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
COMMIT;
|
-- Database Schema Modifications for upgrading from 0.9x to 0.93
|
||||||
|
|
||||||
|
ALTER TABLE device_port ADD COLUMN remote_type text;
|
||||||
|
ALTER TABLE device_port ADD COLUMN remote_id text;
|
||||||
|
ALTER TABLE device_port ADD COLUMN vlan text;
|
||||||
|
|
||||||
|
ALTER TABLE device ADD COLUMN vtp_domain text;
|
||||||
|
|
||||||
|
ALTER TABLE users ADD COLUMN fullname text;
|
||||||
|
ALTER TABLE users ADD COLUMN note text;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|||||||
@@ -1,450 +0,0 @@
|
|||||||
--
|
|
||||||
-- Created by SQL::Translator::Producer::PostgreSQL
|
|
||||||
-- Created on Wed Oct 10 14:24:20 2012
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Table: admin.
|
|
||||||
--
|
|
||||||
DROP TABLE "admin" CASCADE;
|
|
||||||
CREATE TABLE "admin" (
|
|
||||||
"job" serial NOT NULL,
|
|
||||||
"entered" timestamp DEFAULT current_timestamp,
|
|
||||||
"started" timestamp,
|
|
||||||
"finished" timestamp,
|
|
||||||
"device" inet,
|
|
||||||
"port" text,
|
|
||||||
"action" text,
|
|
||||||
"subaction" text,
|
|
||||||
"status" text,
|
|
||||||
"username" text,
|
|
||||||
"userip" inet,
|
|
||||||
"log" text,
|
|
||||||
"debug" boolean
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device.
|
|
||||||
--
|
|
||||||
DROP TABLE "device" CASCADE;
|
|
||||||
CREATE TABLE "device" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"dns" text,
|
|
||||||
"description" text,
|
|
||||||
"uptime" bigint,
|
|
||||||
"contact" text,
|
|
||||||
"name" text,
|
|
||||||
"location" text,
|
|
||||||
"layers" character varying(8),
|
|
||||||
"ports" integer,
|
|
||||||
"mac" macaddr,
|
|
||||||
"serial" text,
|
|
||||||
"model" text,
|
|
||||||
"ps1_type" text,
|
|
||||||
"ps2_type" text,
|
|
||||||
"ps1_status" text,
|
|
||||||
"ps2_status" text,
|
|
||||||
"fan" text,
|
|
||||||
"slots" integer,
|
|
||||||
"vendor" text,
|
|
||||||
"os" text,
|
|
||||||
"os_ver" text,
|
|
||||||
"log" text,
|
|
||||||
"snmp_ver" integer,
|
|
||||||
"snmp_comm" text,
|
|
||||||
"snmp_class" text,
|
|
||||||
"vtp_domain" text,
|
|
||||||
"last_discover" timestamp,
|
|
||||||
"last_macsuck" timestamp,
|
|
||||||
"last_arpnip" timestamp,
|
|
||||||
PRIMARY KEY ("ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_module.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_module" CASCADE;
|
|
||||||
CREATE TABLE "device_module" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"index" integer NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"type" text,
|
|
||||||
"parent" integer,
|
|
||||||
"name" text,
|
|
||||||
"class" text,
|
|
||||||
"pos" integer,
|
|
||||||
"hw_ver" text,
|
|
||||||
"fw_ver" text,
|
|
||||||
"sw_ver" text,
|
|
||||||
"serial" text,
|
|
||||||
"model" text,
|
|
||||||
"fru" boolean,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp,
|
|
||||||
PRIMARY KEY ("ip", "index")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_log.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_log" CASCADE;
|
|
||||||
CREATE TABLE "device_port_log" (
|
|
||||||
"id" serial NOT NULL,
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"reason" text,
|
|
||||||
"log" text,
|
|
||||||
"username" text,
|
|
||||||
"userip" inet,
|
|
||||||
"action" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_power.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_power" CASCADE;
|
|
||||||
CREATE TABLE "device_port_power" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"module" integer,
|
|
||||||
"admin" text,
|
|
||||||
"status" text,
|
|
||||||
"class" text,
|
|
||||||
"power" integer,
|
|
||||||
PRIMARY KEY ("port", "ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_ssid.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_ssid" CASCADE;
|
|
||||||
CREATE TABLE "device_port_ssid" (
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"ssid" text,
|
|
||||||
"broadcast" boolean
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_wireless.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_wireless" CASCADE;
|
|
||||||
CREATE TABLE "device_port_wireless" (
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"channel" integer,
|
|
||||||
"power" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_power.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_power" CASCADE;
|
|
||||||
CREATE TABLE "device_power" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"module" integer NOT NULL,
|
|
||||||
"power" integer,
|
|
||||||
"status" text,
|
|
||||||
PRIMARY KEY ("ip", "module")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_route.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_route" CASCADE;
|
|
||||||
CREATE TABLE "device_route" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"network" cidr NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"dest" inet NOT NULL,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "network", "dest")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: log.
|
|
||||||
--
|
|
||||||
DROP TABLE "log" CASCADE;
|
|
||||||
CREATE TABLE "log" (
|
|
||||||
"id" serial NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"class" text,
|
|
||||||
"entry" text,
|
|
||||||
"logfile" text
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_ip.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_ip" CASCADE;
|
|
||||||
CREATE TABLE "node_ip" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac", "ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_monitor.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_monitor" CASCADE;
|
|
||||||
CREATE TABLE "node_monitor" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"why" text,
|
|
||||||
"cc" text,
|
|
||||||
"date" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_nbt.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_nbt" CASCADE;
|
|
||||||
CREATE TABLE "node_nbt" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"ip" inet,
|
|
||||||
"nbname" text,
|
|
||||||
"domain" text,
|
|
||||||
"server" boolean,
|
|
||||||
"nbuser" text,
|
|
||||||
"active" boolean,
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_wireless.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_wireless" CASCADE;
|
|
||||||
CREATE TABLE "node_wireless" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"uptime" integer,
|
|
||||||
"maxrate" integer,
|
|
||||||
"txrate" integer,
|
|
||||||
"sigstrength" integer,
|
|
||||||
"sigqual" integer,
|
|
||||||
"rxpkt" integer,
|
|
||||||
"txpkt" integer,
|
|
||||||
"rxbyte" bigint,
|
|
||||||
"txbyte" bigint,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: oui.
|
|
||||||
--
|
|
||||||
DROP TABLE "oui" CASCADE;
|
|
||||||
CREATE TABLE "oui" (
|
|
||||||
"oui" character varying(8) NOT NULL,
|
|
||||||
"company" text,
|
|
||||||
PRIMARY KEY ("oui")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: process.
|
|
||||||
--
|
|
||||||
DROP TABLE "process" CASCADE;
|
|
||||||
CREATE TABLE "process" (
|
|
||||||
"controller" integer NOT NULL,
|
|
||||||
"device" inet NOT NULL,
|
|
||||||
"action" text NOT NULL,
|
|
||||||
"status" text,
|
|
||||||
"count" integer,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: sessions.
|
|
||||||
--
|
|
||||||
DROP TABLE "sessions" CASCADE;
|
|
||||||
CREATE TABLE "sessions" (
|
|
||||||
"id" character(32) NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"a_session" text,
|
|
||||||
PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: subnets.
|
|
||||||
--
|
|
||||||
DROP TABLE "subnets" CASCADE;
|
|
||||||
CREATE TABLE "subnets" (
|
|
||||||
"net" cidr NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("net")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: user_log.
|
|
||||||
--
|
|
||||||
DROP TABLE "user_log" CASCADE;
|
|
||||||
CREATE TABLE "user_log" (
|
|
||||||
"entry" serial NOT NULL,
|
|
||||||
"username" character varying(50),
|
|
||||||
"userip" inet,
|
|
||||||
"event" text,
|
|
||||||
"details" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: users.
|
|
||||||
--
|
|
||||||
DROP TABLE "users" CASCADE;
|
|
||||||
CREATE TABLE "users" (
|
|
||||||
"username" character varying(50) NOT NULL,
|
|
||||||
"password" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_on" timestamp,
|
|
||||||
"port_control" boolean DEFAULT false,
|
|
||||||
"ldap" boolean DEFAULT false,
|
|
||||||
"admin" boolean DEFAULT false,
|
|
||||||
"fullname" text,
|
|
||||||
"note" text,
|
|
||||||
PRIMARY KEY ("username")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_vlan.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_vlan" CASCADE;
|
|
||||||
CREATE TABLE "device_vlan" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"vlan" integer NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_vlan_idx_ip" on "device_vlan" ("ip");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_ip.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_ip" CASCADE;
|
|
||||||
CREATE TABLE "device_ip" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"alias" inet NOT NULL,
|
|
||||||
"subnet" cidr,
|
|
||||||
"port" text,
|
|
||||||
"dns" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "alias"),
|
|
||||||
CONSTRAINT "device_ip_alias" UNIQUE ("alias")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_ip_idx_ip" on "device_ip" ("ip");
|
|
||||||
CREATE INDEX "device_ip_idx_ip_port" on "device_ip" ("ip", "port");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port" CASCADE;
|
|
||||||
CREATE TABLE "device_port" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"descr" text,
|
|
||||||
"up" text,
|
|
||||||
"up_admin" text,
|
|
||||||
"type" text,
|
|
||||||
"duplex" text,
|
|
||||||
"duplex_admin" text,
|
|
||||||
"speed" text,
|
|
||||||
"name" text,
|
|
||||||
"mac" macaddr,
|
|
||||||
"mtu" integer,
|
|
||||||
"stp" text,
|
|
||||||
"remote_ip" inet,
|
|
||||||
"remote_port" text,
|
|
||||||
"remote_type" text,
|
|
||||||
"remote_id" text,
|
|
||||||
"vlan" text,
|
|
||||||
"pvid" integer,
|
|
||||||
"lastchange" bigint,
|
|
||||||
PRIMARY KEY ("port", "ip")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_idx_ip" on "device_port" ("ip");
|
|
||||||
CREATE INDEX "device_port_idx_remote_ip" on "device_port" ("remote_ip");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_vlan.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_vlan" CASCADE;
|
|
||||||
CREATE TABLE "device_port_vlan" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"vlan" integer NOT NULL,
|
|
||||||
"native" boolean DEFAULT false NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "port", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip" on "device_port_vlan" ("ip");
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip_port" on "device_port_vlan" ("ip", "port");
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip_vlan" on "device_port_vlan" ("ip", "vlan");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node.
|
|
||||||
--
|
|
||||||
DROP TABLE "node" CASCADE;
|
|
||||||
CREATE TABLE "node" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"switch" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"oui" character varying(8),
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_recent" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac", "switch", "port")
|
|
||||||
);
|
|
||||||
CREATE INDEX "node_idx_switch" on "node" ("switch");
|
|
||||||
CREATE INDEX "node_idx_switch_port" on "node" ("switch", "port");
|
|
||||||
CREATE INDEX "node_idx_oui" on "node" ("oui");
|
|
||||||
|
|
||||||
-- Not used in Netdisco, because they upset the legacy netdisco.pm code
|
|
||||||
--
|
|
||||||
-- --
|
|
||||||
-- -- Foreign Key Definitions
|
|
||||||
-- --
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_vlan" ADD CONSTRAINT "device_vlan_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_ip" ADD CONSTRAINT "device_ip_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_ip" ADD CONSTRAINT "device_ip_fk_ip_port" FOREIGN KEY ("ip", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port" ADD CONSTRAINT "device_port_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port" ADD CONSTRAINT "device_port_fk_remote_ip" FOREIGN KEY ("remote_ip")
|
|
||||||
-- REFERENCES "device_ip" ("alias") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD CONSTRAINT "device_port_vlan_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD CONSTRAINT "device_port_vlan_fk_ip_port" FOREIGN KEY ("ip", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD CONSTRAINT "device_port_vlan_fk_ip_vlan" FOREIGN KEY ("ip", "vlan")
|
|
||||||
-- REFERENCES "device_vlan" ("ip", "vlan") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD CONSTRAINT "node_fk_switch" FOREIGN KEY ("switch")
|
|
||||||
-- REFERENCES "device" ("ip") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD CONSTRAINT "node_fk_switch_port" FOREIGN KEY ("switch", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD CONSTRAINT "node_fk_oui" FOREIGN KEY ("oui")
|
|
||||||
-- REFERENCES "oui" ("oui") DEFERRABLE;
|
|
||||||
--
|
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE device_ip DROP CONSTRAINT "device_ip_alias";
|
CREATE UNIQUE INDEX jobs_queued ON admin (
|
||||||
|
action,
|
||||||
|
coalesce(subaction, '_x_'),
|
||||||
|
coalesce(device, '255.255.255.255'),
|
||||||
|
coalesce(port, '_x_')
|
||||||
|
) WHERE status LIKE 'queued%';
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
-- ALTER TABLE device_port ALTER COLUMN remote_id TYPE bytea USING remote_id::bytea;
|
ALTER TABLE topology ADD CONSTRAINT topology_dev1_port1 UNIQUE (dev1, port1);
|
||||||
|
|
||||||
|
ALTER TABLE topology ADD CONSTRAINT topology_dev2_port2 UNIQUE (dev2, port2);
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
-- ALTER TABLE device_port ALTER COLUMN remote_id TYPE text USING remote_id::text;
|
ALTER TABLE device_port ADD COLUMN "manual_topo" bool DEFAULT false NOT NULL;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE device ADD COLUMN snmp_comm_rw text;
|
ALTER TABLE device_port ADD COLUMN "is_uplink" bool;
|
||||||
|
ALTER TABLE device_port ADD COLUMN "is_uplink_admin" bool;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE device DROP COLUMN snmp_comm_rw;
|
ALTER TABLE device_ip DROP CONSTRAINT "device_ip_alias";
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
CREATE TABLE "community" (
|
-- ALTER TABLE device_port ALTER COLUMN remote_id TYPE bytea USING remote_id::bytea;
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"snmp_comm_rw" text,
|
|
||||||
PRIMARY KEY ("ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE node_wireless ALTER COLUMN rxpkt TYPE bigint;
|
-- ALTER TABLE device_port ALTER COLUMN remote_id TYPE text USING remote_id::text;
|
||||||
ALTER TABLE node_wireless ALTER COLUMN txpkt TYPE bigint;
|
|
||||||
ALTER TABLE node_wireless ALTER COLUMN rxbyte TYPE bigint;
|
|
||||||
ALTER TABLE node_wireless ALTER COLUMN txbyte TYPE bigint;
|
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
DROP INDEX IF EXISTS jobs_queued;
|
ALTER TABLE device ADD COLUMN snmp_comm_rw text;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE community ADD COLUMN snmp_auth_tag text;
|
ALTER TABLE device DROP COLUMN snmp_comm_rw;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
UPDATE node SET vlan = '0' WHERE vlan IS NULL;
|
CREATE TABLE "community" (
|
||||||
|
"ip" inet NOT NULL,
|
||||||
|
"snmp_comm_rw" text,
|
||||||
|
PRIMARY KEY ("ip")
|
||||||
|
);
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,6 +1,38 @@
|
|||||||
-- Convert schema '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-3-PostgreSQL.sql' to '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-4-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
COMMIT;
|
-- Netdisco
|
||||||
|
-- Database Schema Modifications
|
||||||
|
-- UPGRADE from 0.93 to 0.94
|
||||||
|
|
||||||
|
ALTER TABLE device_port ADD COLUMN lastchange bigint;
|
||||||
|
|
||||||
|
ALTER TABLE log ADD COLUMN logfile text;
|
||||||
|
|
||||||
|
CREATE TABLE user_log (
|
||||||
|
entry serial,
|
||||||
|
username varchar(50),
|
||||||
|
userip inet,
|
||||||
|
event text,
|
||||||
|
details text,
|
||||||
|
creation TIMESTAMP DEFAULT now()
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE node_nbt (
|
||||||
|
mac macaddr PRIMARY KEY,
|
||||||
|
ip inet,
|
||||||
|
nbname text,
|
||||||
|
domain text,
|
||||||
|
server boolean,
|
||||||
|
nbuser text,
|
||||||
|
active boolean,
|
||||||
|
time_first timestamp default now(),
|
||||||
|
time_last timestamp default now()
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Indexing speed ups.
|
||||||
|
CREATE INDEX idx_node_nbt_mac ON node_nbt(mac);
|
||||||
|
CREATE INDEX idx_node_nbt_nbname ON node_nbt(nbname);
|
||||||
|
CREATE INDEX idx_node_nbt_domain ON node_nbt(domain);
|
||||||
|
CREATE INDEX idx_node_nbt_mac_active ON node_nbt(mac,active);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
CREATE INDEX node_ip_idx_ip_active ON node_ip (ip, active);
|
ALTER TABLE node_wireless ALTER COLUMN rxpkt TYPE bigint;
|
||||||
|
ALTER TABLE node_wireless ALTER COLUMN txpkt TYPE bigint;
|
||||||
|
ALTER TABLE node_wireless ALTER COLUMN rxbyte TYPE bigint;
|
||||||
|
ALTER TABLE node_wireless ALTER COLUMN txbyte TYPE bigint;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE device_port_vlan DROP CONSTRAINT device_port_vlan_pkey;
|
DROP INDEX IF EXISTS jobs_queued;
|
||||||
|
|
||||||
ALTER TABLE device_port_vlan ADD PRIMARY KEY (ip, port, vlan, native);
|
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE oui ADD COLUMN abbrev text;
|
ALTER TABLE community ADD COLUMN snmp_auth_tag text;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE device_port DROP COLUMN is_uplink_admin;
|
UPDATE node SET vlan = '0' WHERE vlan IS NULL;
|
||||||
ALTER TABLE device_port ADD COLUMN "slave_of" text;
|
|
||||||
ALTER TABLE device_port ADD COLUMN "is_master" bool DEFAULT false NOT NULL;
|
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
CREATE INDEX node_ip_idx_ip_active ON node_ip (ip, active);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE device_port_vlan DROP CONSTRAINT device_port_vlan_pkey;
|
||||||
|
|
||||||
|
ALTER TABLE device_port_vlan ADD PRIMARY KEY (ip, port, vlan, native);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE oui ADD COLUMN abbrev text;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE device_port DROP COLUMN is_uplink_admin;
|
||||||
|
ALTER TABLE device_port ADD COLUMN "slave_of" text;
|
||||||
|
ALTER TABLE device_port ADD COLUMN "is_master" bool DEFAULT false NOT NULL;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
@@ -1,13 +1,59 @@
|
|||||||
-- Convert schema '/home/sy0/git/netdisco-frontend-sandpit/Netdisco/lib/Netdisco/DB/schema_versions/Netdisco-DB-1-PostgreSQL.sql' to '/home/sy0/git/netdisco-frontend-sandpit/Netdisco/lib/Netdisco/DB/schema_versions/Netdisco-DB-2-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
CREATE TABLE "topology" (
|
-- Netdisco
|
||||||
"dev1" inet NOT NULL,
|
-- Database Schema Modifications
|
||||||
"port1" text NOT NULL,
|
-- UPGRADE from 0.94 to 0.95
|
||||||
"dev2" inet NOT NULL,
|
|
||||||
"port2" text NOT NULL
|
CREATE TABLE subnets (
|
||||||
|
net cidr NOT NULL,
|
||||||
|
creation timestamp default now(),
|
||||||
|
last_discover timestamp default now(),
|
||||||
|
PRIMARY KEY(net)
|
||||||
);
|
);
|
||||||
|
|
||||||
COMMIT;
|
--
|
||||||
|
-- node_nbt could already exist, if you upgraded to 0.94, but if
|
||||||
|
-- you ran pg_all in 0.94, node_nbt wasn't created. This
|
||||||
|
-- will report some harmless errors if it already exists.
|
||||||
|
|
||||||
|
CREATE TABLE node_nbt (
|
||||||
|
mac macaddr PRIMARY KEY,
|
||||||
|
ip inet,
|
||||||
|
nbname text,
|
||||||
|
domain text,
|
||||||
|
server boolean,
|
||||||
|
nbuser text,
|
||||||
|
active boolean, -- do we need this still?
|
||||||
|
time_first timestamp default now(),
|
||||||
|
time_last timestamp default now()
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Indexing speed ups.
|
||||||
|
CREATE INDEX idx_node_nbt_mac ON node_nbt(mac);
|
||||||
|
CREATE INDEX idx_node_nbt_nbname ON node_nbt(nbname);
|
||||||
|
CREATE INDEX idx_node_nbt_domain ON node_nbt(domain);
|
||||||
|
CREATE INDEX idx_node_nbt_mac_active ON node_nbt(mac,active);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Add time_recent to node table
|
||||||
|
ALTER TABLE node ADD time_recent timestamp;
|
||||||
|
ALTER TABLE node ALTER time_recent SET DEFAULT now();
|
||||||
|
UPDATE node SET time_recent = time_first WHERE time_recent IS NULL;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Add table to contain wireless base station SSIDs
|
||||||
|
CREATE TABLE device_port_ssid (
|
||||||
|
ip inet, -- ip of device
|
||||||
|
port text, -- Unique identifier of Physical Port Name
|
||||||
|
ssid text, -- An SSID that is valid on this port.
|
||||||
|
broadcast boolean,-- Is it broadcast?
|
||||||
|
channel integer -- 802.11 channel number
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_device_port_ssid_ip_port ON device_port_ssid(ip,port);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- The OUI field in the oui database is now lowercase.
|
||||||
|
UPDATE oui SET oui=lower(oui);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|||||||
@@ -1,8 +1,159 @@
|
|||||||
-- Convert schema '/home/sy0/git/netdisco-frontend-sandpit/Netdisco/lib/Netdisco/DB/schema_versions/Netdisco-DB-1-PostgreSQL.sql' to '/home/sy0/git/netdisco-frontend-sandpit/Netdisco/lib/Netdisco/DB/schema_versions/Netdisco-DB-2-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE device_port_ssid ADD COLUMN bssid macaddr;
|
-- Netdisco
|
||||||
|
-- Database Schema Modifications
|
||||||
|
-- UPGRADE from 0.95 to 0.96
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Add snmp_class to device table
|
||||||
|
ALTER TABLE device ADD snmp_class text;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Add subnet to device_ip table
|
||||||
|
ALTER TABLE device_ip ADD subnet cidr;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Add indexes on admin table
|
||||||
|
CREATE INDEX idx_admin_entered ON admin(entered);
|
||||||
|
CREATE INDEX idx_admin_status ON admin(status);
|
||||||
|
CREATE INDEX idx_admin_action ON admin(action);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Create device_module table
|
||||||
|
CREATE TABLE device_module (
|
||||||
|
ip inet not null,
|
||||||
|
index integer,
|
||||||
|
description text,
|
||||||
|
type text,
|
||||||
|
parent integer,
|
||||||
|
name text,
|
||||||
|
class text,
|
||||||
|
pos integer,
|
||||||
|
hw_ver text,
|
||||||
|
fw_ver text,
|
||||||
|
sw_ver text,
|
||||||
|
serial text,
|
||||||
|
model text,
|
||||||
|
fru boolean,
|
||||||
|
creation TIMESTAMP DEFAULT now(),
|
||||||
|
last_discover TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Earlier versions of device_module didn't have the index
|
||||||
|
ALTER TABLE device_module ADD PRIMARY KEY(ip,index);
|
||||||
|
|
||||||
|
-- Create process table - Queue to coordinate between processes in multi-process mode.
|
||||||
|
CREATE TABLE process (
|
||||||
|
controller integer not null, -- pid of controlling process
|
||||||
|
device inet not null,
|
||||||
|
action text not null, -- arpnip, macsuck, nbtstat, discover
|
||||||
|
status text, -- queued, running, skipped, done, error, timeout, nocdp, nosnmp
|
||||||
|
count integer,
|
||||||
|
creation TIMESTAMP DEFAULT now()
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Earlier versions of the process table didn't have the creation timestamp
|
||||||
|
ALTER TABLE process ADD creation TIMESTAMP DEFAULT now();
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Add ldap to users table
|
||||||
|
ALTER TABLE users ADD ldap boolean;
|
||||||
|
ALTER TABLE users ALTER ldap SET DEFAULT false;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Add pvid to device_port table
|
||||||
|
ALTER TABLE device_port ADD pvid integer;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Create device_port_vlan table
|
||||||
|
CREATE TABLE device_port_vlan (
|
||||||
|
ip inet, -- ip of device
|
||||||
|
port text, -- Unique identifier of Physical Port Name
|
||||||
|
vlan integer, -- VLAN ID
|
||||||
|
native boolean not null default false, -- native or trunked
|
||||||
|
creation TIMESTAMP DEFAULT now(),
|
||||||
|
last_discover TIMESTAMP DEFAULT now(),
|
||||||
|
PRIMARY KEY(ip,port,vlan)
|
||||||
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Create device_vlan table
|
||||||
|
CREATE TABLE device_vlan (
|
||||||
|
ip inet, -- ip of device
|
||||||
|
vlan integer, -- VLAN ID
|
||||||
|
description text, -- VLAN description
|
||||||
|
creation TIMESTAMP DEFAULT now(),
|
||||||
|
last_discover TIMESTAMP DEFAULT now(),
|
||||||
|
PRIMARY KEY(ip,vlan)
|
||||||
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Create device_power table
|
||||||
|
CREATE TABLE device_power (
|
||||||
|
ip inet, -- ip of device
|
||||||
|
module integer,-- Module from PowerEthernet index
|
||||||
|
power integer,-- nominal power of the PSE expressed in Watts
|
||||||
|
status text, -- The operational status
|
||||||
|
PRIMARY KEY(ip,module)
|
||||||
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Create device_port_power table
|
||||||
|
CREATE TABLE device_port_power (
|
||||||
|
ip inet, -- ip of device
|
||||||
|
port text, -- Unique identifier of Physical Port Name
|
||||||
|
module integer,-- Module from PowerEthernet index
|
||||||
|
admin text, -- Admin power status
|
||||||
|
status text, -- Detected power status
|
||||||
|
class text, -- Detected class
|
||||||
|
PRIMARY KEY(port,ip)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE device_port_wireless (
|
||||||
|
ip inet, -- ip of device
|
||||||
|
port text, -- Unique identifier of Physical Port Name
|
||||||
|
channel integer,-- 802.11 channel number
|
||||||
|
power integer -- transmit power in mw
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_device_port_wireless_ip_port ON device_port_wireless(ip,port);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- device_port_ssid lost its channel column, it moved to device_port_wireless
|
||||||
|
--
|
||||||
|
-- Migrate any existing data
|
||||||
|
INSERT INTO device_port_wireless ( ip,port,channel ) ( SELECT ip,port,channel FROM device_port_ssid WHERE channel IS NOT NULL );
|
||||||
|
|
||||||
|
ALTER TABLE device_port_ssid DROP channel;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- node_wireless, for client association information
|
||||||
|
CREATE TABLE node_wireless (
|
||||||
|
mac macaddr,
|
||||||
|
uptime integer,
|
||||||
|
maxrate integer, -- can be 0.5 but we ignore that for now
|
||||||
|
txrate integer, -- can be 0.5 but we ignore that for now
|
||||||
|
sigstrength integer, -- signal strength (-db)
|
||||||
|
sigqual integer, -- signal quality
|
||||||
|
rxpkt integer, -- received packets
|
||||||
|
txpkt integer, -- transmitted packets
|
||||||
|
rxbyte bigint, -- received bytes
|
||||||
|
txbyte bigint, -- transmitted bytes
|
||||||
|
time_last timestamp default now(),
|
||||||
|
PRIMARY KEY(mac)
|
||||||
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- node_monitor, for lost/stolen device monitoring
|
||||||
|
CREATE TABLE node_monitor (
|
||||||
|
mac macaddr,
|
||||||
|
active boolean,
|
||||||
|
why text,
|
||||||
|
cc text,
|
||||||
|
date TIMESTAMP DEFAULT now(),
|
||||||
|
PRIMARY KEY(mac)
|
||||||
|
);
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
-- Convert schema '/home/sy0/git/netdisco-frontend-sandpit/Netdisco/lib/Netdisco/DB/schema_versions/Netdisco-DB-1-PostgreSQL.sql' to '/home/sy0/git/netdisco-frontend-sandpit/Netdisco/lib/Netdisco/DB/schema_versions/Netdisco-DB-2-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE device_port_vlan ADD COLUMN vlantype text;
|
-- Netdisco
|
||||||
|
-- Database Schema Modifications
|
||||||
|
-- UPGRADE from 1.0 to 1.1
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Add index to node_ip table
|
||||||
|
CREATE INDEX idx_node_ip_ip_active ON node_ip(ip,active);
|
||||||
|
|
||||||
|
-- Add "power" column to device_port_power table
|
||||||
|
ALTER TABLE device_port_power ADD power integer;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,33 @@
|
|||||||
-- Convert schema '/home/sy0/git/netdisco-frontend-sandpit/Netdisco/lib/Netdisco/DB/schema_versions/Netdisco-DB-1-PostgreSQL.sql' to '/home/sy0/git/netdisco-frontend-sandpit/Netdisco/lib/Netdisco/DB/schema_versions/Netdisco-DB-2-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE node_ip ADD COLUMN dns text;
|
-- Netdisco
|
||||||
|
-- Database Schema Modifications
|
||||||
|
-- UPGRADE from 1.1 to 1.2
|
||||||
|
|
||||||
|
-- Add "vlantype" column to device_port_vlan table
|
||||||
|
ALTER TABLE device_port_vlan ADD vlantype text;
|
||||||
|
|
||||||
|
-- Add "topology" table to augment manual topo file
|
||||||
|
CREATE TABLE topology (
|
||||||
|
dev1 inet not null,
|
||||||
|
port1 text not null,
|
||||||
|
dev2 inet not null,
|
||||||
|
port2 text not null
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Add "bssid" column to device_port_ssid table
|
||||||
|
ALTER TABLE device_port_ssid ADD bssid macaddr;
|
||||||
|
|
||||||
|
-- Add "vlan" column to node table
|
||||||
|
ALTER TABLE node ADD vlan text DEFAULT '0';
|
||||||
|
|
||||||
|
ALTER TABLE node DROP CONSTRAINT node_pkey;
|
||||||
|
ALTER TABLE node ADD PRIMARY KEY key (mac, switch, port, vlan);
|
||||||
|
|
||||||
|
-- Add "ssid" column to node_wireless table
|
||||||
|
ALTER TABLE node_wireless ADD ssid text DEFAULT '';
|
||||||
|
|
||||||
|
ALTER TABLE node_wireless DROP CONSTRAINT node_wireless_pkey;
|
||||||
|
ALTER TABLE node_wireless ADD PRIMARY KEY (mac, ssid);
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
-- Convert schema '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-3-PostgreSQL.sql' to '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-4-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE node DROP CONSTRAINT node_pkey;
|
CREATE TABLE "topology" (
|
||||||
|
"dev1" inet NOT NULL,
|
||||||
|
"port1" text NOT NULL,
|
||||||
|
"dev2" inet NOT NULL,
|
||||||
|
"port2" text NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,464 +0,0 @@
|
|||||||
--
|
|
||||||
-- Created by SQL::Translator::Producer::PostgreSQL
|
|
||||||
-- Created on Wed Oct 10 15:38:36 2012
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Table: admin.
|
|
||||||
--
|
|
||||||
DROP TABLE "admin" CASCADE;
|
|
||||||
CREATE TABLE "admin" (
|
|
||||||
"job" serial NOT NULL,
|
|
||||||
"entered" timestamp DEFAULT current_timestamp,
|
|
||||||
"started" timestamp,
|
|
||||||
"finished" timestamp,
|
|
||||||
"device" inet,
|
|
||||||
"port" text,
|
|
||||||
"action" text,
|
|
||||||
"subaction" text,
|
|
||||||
"status" text,
|
|
||||||
"username" text,
|
|
||||||
"userip" inet,
|
|
||||||
"log" text,
|
|
||||||
"debug" boolean
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device.
|
|
||||||
--
|
|
||||||
DROP TABLE "device" CASCADE;
|
|
||||||
CREATE TABLE "device" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"dns" text,
|
|
||||||
"description" text,
|
|
||||||
"uptime" bigint,
|
|
||||||
"contact" text,
|
|
||||||
"name" text,
|
|
||||||
"location" text,
|
|
||||||
"layers" character varying(8),
|
|
||||||
"ports" integer,
|
|
||||||
"mac" macaddr,
|
|
||||||
"serial" text,
|
|
||||||
"model" text,
|
|
||||||
"ps1_type" text,
|
|
||||||
"ps2_type" text,
|
|
||||||
"ps1_status" text,
|
|
||||||
"ps2_status" text,
|
|
||||||
"fan" text,
|
|
||||||
"slots" integer,
|
|
||||||
"vendor" text,
|
|
||||||
"os" text,
|
|
||||||
"os_ver" text,
|
|
||||||
"log" text,
|
|
||||||
"snmp_ver" integer,
|
|
||||||
"snmp_comm" text,
|
|
||||||
"snmp_class" text,
|
|
||||||
"vtp_domain" text,
|
|
||||||
"last_discover" timestamp,
|
|
||||||
"last_macsuck" timestamp,
|
|
||||||
"last_arpnip" timestamp,
|
|
||||||
PRIMARY KEY ("ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_module.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_module" CASCADE;
|
|
||||||
CREATE TABLE "device_module" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"index" integer NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"type" text,
|
|
||||||
"parent" integer,
|
|
||||||
"name" text,
|
|
||||||
"class" text,
|
|
||||||
"pos" integer,
|
|
||||||
"hw_ver" text,
|
|
||||||
"fw_ver" text,
|
|
||||||
"sw_ver" text,
|
|
||||||
"serial" text,
|
|
||||||
"model" text,
|
|
||||||
"fru" boolean,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp,
|
|
||||||
PRIMARY KEY ("ip", "index")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_log.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_log" CASCADE;
|
|
||||||
CREATE TABLE "device_port_log" (
|
|
||||||
"id" serial NOT NULL,
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"reason" text,
|
|
||||||
"log" text,
|
|
||||||
"username" text,
|
|
||||||
"userip" inet,
|
|
||||||
"action" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_power.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_power" CASCADE;
|
|
||||||
CREATE TABLE "device_port_power" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"module" integer,
|
|
||||||
"admin" text,
|
|
||||||
"status" text,
|
|
||||||
"class" text,
|
|
||||||
"power" integer,
|
|
||||||
PRIMARY KEY ("port", "ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_ssid.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_ssid" CASCADE;
|
|
||||||
CREATE TABLE "device_port_ssid" (
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"ssid" text,
|
|
||||||
"broadcast" boolean,
|
|
||||||
"bssid" macaddr
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_wireless.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_wireless" CASCADE;
|
|
||||||
CREATE TABLE "device_port_wireless" (
|
|
||||||
"ip" inet,
|
|
||||||
"port" text,
|
|
||||||
"channel" integer,
|
|
||||||
"power" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_power.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_power" CASCADE;
|
|
||||||
CREATE TABLE "device_power" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"module" integer NOT NULL,
|
|
||||||
"power" integer,
|
|
||||||
"status" text,
|
|
||||||
PRIMARY KEY ("ip", "module")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_route.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_route" CASCADE;
|
|
||||||
CREATE TABLE "device_route" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"network" cidr NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"dest" inet NOT NULL,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "network", "dest")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: log.
|
|
||||||
--
|
|
||||||
DROP TABLE "log" CASCADE;
|
|
||||||
CREATE TABLE "log" (
|
|
||||||
"id" serial NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"class" text,
|
|
||||||
"entry" text,
|
|
||||||
"logfile" text
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_ip.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_ip" CASCADE;
|
|
||||||
CREATE TABLE "node_ip" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
"dns" text,
|
|
||||||
PRIMARY KEY ("mac", "ip")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_monitor.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_monitor" CASCADE;
|
|
||||||
CREATE TABLE "node_monitor" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"why" text,
|
|
||||||
"cc" text,
|
|
||||||
"date" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_nbt.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_nbt" CASCADE;
|
|
||||||
CREATE TABLE "node_nbt" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"ip" inet,
|
|
||||||
"nbname" text,
|
|
||||||
"domain" text,
|
|
||||||
"server" boolean,
|
|
||||||
"nbuser" text,
|
|
||||||
"active" boolean,
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node_wireless.
|
|
||||||
--
|
|
||||||
DROP TABLE "node_wireless" CASCADE;
|
|
||||||
CREATE TABLE "node_wireless" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"uptime" integer,
|
|
||||||
"maxrate" integer,
|
|
||||||
"txrate" integer,
|
|
||||||
"sigstrength" integer,
|
|
||||||
"sigqual" integer,
|
|
||||||
"rxpkt" integer,
|
|
||||||
"txpkt" integer,
|
|
||||||
"rxbyte" bigint,
|
|
||||||
"txbyte" bigint,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: oui.
|
|
||||||
--
|
|
||||||
DROP TABLE "oui" CASCADE;
|
|
||||||
CREATE TABLE "oui" (
|
|
||||||
"oui" character varying(8) NOT NULL,
|
|
||||||
"company" text,
|
|
||||||
PRIMARY KEY ("oui")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: process.
|
|
||||||
--
|
|
||||||
DROP TABLE "process" CASCADE;
|
|
||||||
CREATE TABLE "process" (
|
|
||||||
"controller" integer NOT NULL,
|
|
||||||
"device" inet NOT NULL,
|
|
||||||
"action" text NOT NULL,
|
|
||||||
"status" text,
|
|
||||||
"count" integer,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: sessions.
|
|
||||||
--
|
|
||||||
DROP TABLE "sessions" CASCADE;
|
|
||||||
CREATE TABLE "sessions" (
|
|
||||||
"id" character(32) NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"a_session" text,
|
|
||||||
PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: subnets.
|
|
||||||
--
|
|
||||||
DROP TABLE "subnets" CASCADE;
|
|
||||||
CREATE TABLE "subnets" (
|
|
||||||
"net" cidr NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("net")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: topology.
|
|
||||||
--
|
|
||||||
DROP TABLE "topology" CASCADE;
|
|
||||||
CREATE TABLE "topology" (
|
|
||||||
"dev1" inet NOT NULL,
|
|
||||||
"port1" text NOT NULL,
|
|
||||||
"dev2" inet NOT NULL,
|
|
||||||
"port2" text NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: user_log.
|
|
||||||
--
|
|
||||||
DROP TABLE "user_log" CASCADE;
|
|
||||||
CREATE TABLE "user_log" (
|
|
||||||
"entry" serial NOT NULL,
|
|
||||||
"username" character varying(50),
|
|
||||||
"userip" inet,
|
|
||||||
"event" text,
|
|
||||||
"details" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: users.
|
|
||||||
--
|
|
||||||
DROP TABLE "users" CASCADE;
|
|
||||||
CREATE TABLE "users" (
|
|
||||||
"username" character varying(50) NOT NULL,
|
|
||||||
"password" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_on" timestamp,
|
|
||||||
"port_control" boolean DEFAULT false,
|
|
||||||
"ldap" boolean DEFAULT false,
|
|
||||||
"admin" boolean DEFAULT false,
|
|
||||||
"fullname" text,
|
|
||||||
"note" text,
|
|
||||||
PRIMARY KEY ("username")
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_vlan.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_vlan" CASCADE;
|
|
||||||
CREATE TABLE "device_vlan" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"vlan" integer NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_vlan_idx_ip" on "device_vlan" ("ip");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_ip.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_ip" CASCADE;
|
|
||||||
CREATE TABLE "device_ip" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"alias" inet NOT NULL,
|
|
||||||
"subnet" cidr,
|
|
||||||
"port" text,
|
|
||||||
"dns" text,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("ip", "alias"),
|
|
||||||
CONSTRAINT "device_ip_alias" UNIQUE ("alias")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_ip_idx_ip" on "device_ip" ("ip");
|
|
||||||
CREATE INDEX "device_ip_idx_ip_port" on "device_ip" ("ip", "port");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port" CASCADE;
|
|
||||||
CREATE TABLE "device_port" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"descr" text,
|
|
||||||
"up" text,
|
|
||||||
"up_admin" text,
|
|
||||||
"type" text,
|
|
||||||
"duplex" text,
|
|
||||||
"duplex_admin" text,
|
|
||||||
"speed" text,
|
|
||||||
"name" text,
|
|
||||||
"mac" macaddr,
|
|
||||||
"mtu" integer,
|
|
||||||
"stp" text,
|
|
||||||
"remote_ip" inet,
|
|
||||||
"remote_port" text,
|
|
||||||
"remote_type" text,
|
|
||||||
"remote_id" text,
|
|
||||||
"vlan" text,
|
|
||||||
"pvid" integer,
|
|
||||||
"lastchange" bigint,
|
|
||||||
PRIMARY KEY ("port", "ip")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_idx_ip" on "device_port" ("ip");
|
|
||||||
CREATE INDEX "device_port_idx_remote_ip" on "device_port" ("remote_ip");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: device_port_vlan.
|
|
||||||
--
|
|
||||||
DROP TABLE "device_port_vlan" CASCADE;
|
|
||||||
CREATE TABLE "device_port_vlan" (
|
|
||||||
"ip" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"vlan" integer NOT NULL,
|
|
||||||
"native" boolean DEFAULT false NOT NULL,
|
|
||||||
"creation" timestamp DEFAULT current_timestamp,
|
|
||||||
"last_discover" timestamp DEFAULT current_timestamp,
|
|
||||||
"vlantype" text,
|
|
||||||
PRIMARY KEY ("ip", "port", "vlan")
|
|
||||||
);
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip" on "device_port_vlan" ("ip");
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip_port" on "device_port_vlan" ("ip", "port");
|
|
||||||
CREATE INDEX "device_port_vlan_idx_ip_vlan" on "device_port_vlan" ("ip", "vlan");
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table: node.
|
|
||||||
--
|
|
||||||
DROP TABLE "node" CASCADE;
|
|
||||||
CREATE TABLE "node" (
|
|
||||||
"mac" macaddr NOT NULL,
|
|
||||||
"switch" inet NOT NULL,
|
|
||||||
"port" text NOT NULL,
|
|
||||||
"active" boolean,
|
|
||||||
"oui" character varying(8),
|
|
||||||
"time_first" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_recent" timestamp DEFAULT current_timestamp,
|
|
||||||
"time_last" timestamp DEFAULT current_timestamp,
|
|
||||||
PRIMARY KEY ("mac", "switch", "port")
|
|
||||||
);
|
|
||||||
CREATE INDEX "node_idx_switch" on "node" ("switch");
|
|
||||||
CREATE INDEX "node_idx_switch_port" on "node" ("switch", "port");
|
|
||||||
CREATE INDEX "node_idx_oui" on "node" ("oui");
|
|
||||||
|
|
||||||
-- Not used in Netdisco, because they upset the legacy netdisco.pm code
|
|
||||||
--
|
|
||||||
-- --
|
|
||||||
-- -- Foreign Key Definitions
|
|
||||||
-- --
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_vlan" ADD CONSTRAINT "device_vlan_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_ip" ADD CONSTRAINT "device_ip_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_ip" ADD CONSTRAINT "device_ip_fk_ip_port" FOREIGN KEY ("ip", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port" ADD CONSTRAINT "device_port_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port" ADD CONSTRAINT "device_port_fk_remote_ip" FOREIGN KEY ("remote_ip")
|
|
||||||
-- REFERENCES "device_ip" ("alias") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD CONSTRAINT "device_port_vlan_fk_ip" FOREIGN KEY ("ip")
|
|
||||||
-- REFERENCES "device" ("ip") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD CONSTRAINT "device_port_vlan_fk_ip_port" FOREIGN KEY ("ip", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "device_port_vlan" ADD CONSTRAINT "device_port_vlan_fk_ip_vlan" FOREIGN KEY ("ip", "vlan")
|
|
||||||
-- REFERENCES "device_vlan" ("ip", "vlan") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD CONSTRAINT "node_fk_switch" FOREIGN KEY ("switch")
|
|
||||||
-- REFERENCES "device" ("ip") DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD CONSTRAINT "node_fk_switch_port" FOREIGN KEY ("switch", "port")
|
|
||||||
-- REFERENCES "device_port" ("ip", "port") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
--
|
|
||||||
-- ALTER TABLE "node" ADD CONSTRAINT "node_fk_oui" FOREIGN KEY ("oui")
|
|
||||||
-- REFERENCES "oui" ("oui") DEFERRABLE;
|
|
||||||
--
|
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
-- Convert schema '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-3-PostgreSQL.sql' to '/home/oliver/git/netdisco-frontend-sandpit/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-4-PostgreSQL.sql':;
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
ALTER TABLE node_wireless DROP CONSTRAINT node_wireless_pkey;
|
ALTER TABLE device_port_ssid ADD COLUMN bssid macaddr;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user