permit DB schema upgrades from any 0.x and 1.x ver

This commit is contained in:
Oliver Gorwits
2014-02-08 16:08:15 +00:00
parent eaf362a5e8
commit f8cf6aad73
44 changed files with 697 additions and 2313 deletions

View File

@@ -10,7 +10,7 @@ __PACKAGE__->load_namespaces(
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 File::Basename;

View File

@@ -1,425 +1,372 @@
--
-- Created by SQL::Translator::Producer::PostgreSQL
-- Created on Wed Oct 10 14:24:20 2012
--
--
-- Table: admin.
--
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
BEGIN;
-- admin table - Queue for admin tasks sent from front-end for back-end processing.
CREATE TABLE admin (
job serial,
entered TIMESTAMP DEFAULT now(),
started TIMESTAMP,
finished TIMESTAMP,
device inet,
port text,
action text,
subaction text,
status text,
username text,
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
);
--
-- Table: device.
--
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")
-- Indexing for speed-ups
CREATE INDEX idx_device_dns ON device(dns);
CREATE INDEX idx_device_layers ON device(layers);
CREATE INDEX idx_device_vendor ON device(vendor);
CREATE INDEX idx_device_model ON device(model);
CREATE TABLE device_ip (
ip inet,
alias inet,
subnet cidr,
port text,
dns text,
creation TIMESTAMP DEFAULT now(),
PRIMARY KEY(ip,alias)
);
--
-- Table: device_module.
--
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")
-- Indexing for speed ups
CREATE INDEX idx_device_ip_ip ON device_ip(ip);
CREATE INDEX idx_device_ip_alias ON device_ip(alias);
CREATE INDEX idx_device_ip_ip_port ON device_ip(ip,port);
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,
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)
);
--
-- Table: device_port_log.
--
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
CREATE INDEX idx_device_port_ip ON device_port(ip);
CREATE INDEX idx_device_port_remote_ip ON device_port(remote_ip);
-- For the duplex mismatch finder :
CREATE INDEX idx_device_port_ip_port_duplex ON device_port(ip,port,duplex);
CREATE INDEX idx_device_port_ip_up_admin ON device_port(ip,up_admin);
CREATE INDEX idx_device_port_mac ON device_port(mac);
CREATE TABLE device_port_log (
id serial,
ip inet,
port text,
reason text,
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)
);
--
-- Table: device_port_power.
--
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 TABLE device_port_ssid (
ip inet,
port text,
ssid text,
broadcast boolean,
bssid macaddr
);
--
-- Table: device_port_ssid.
--
CREATE TABLE "device_port_ssid" (
"ip" inet,
"port" text,
"ssid" text,
"broadcast" boolean
CREATE INDEX idx_device_port_ssid_ip_port ON device_port_ssid(ip,port);
CREATE TABLE device_port_vlan (
ip inet,
port text,
vlan integer,
native boolean not null default false,
creation TIMESTAMP DEFAULT now(),
last_discover TIMESTAMP DEFAULT now(),
vlantype text,
PRIMARY KEY(ip,port,vlan)
);
--
-- Table: device_port_wireless.
--
CREATE TABLE "device_port_wireless" (
"ip" inet,
"port" text,
"channel" integer,
"power" integer
CREATE TABLE device_port_wireless (
ip inet,
port text,
channel integer,
power integer
);
--
-- Table: device_power.
--
CREATE TABLE "device_power" (
"ip" inet NOT NULL,
"module" integer NOT NULL,
"power" integer,
"status" text,
PRIMARY KEY ("ip", "module")
CREATE INDEX idx_device_port_wireless_ip_port ON device_port_wireless(ip,port);
CREATE TABLE device_power (
ip inet,
module integer,
power integer,
status text,
PRIMARY KEY(ip,module)
);
--
-- Table: device_route.
--
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")
CREATE TABLE device_vlan (
ip inet,
vlan integer,
description text,
creation TIMESTAMP DEFAULT now(),
last_discover TIMESTAMP DEFAULT now(),
PRIMARY KEY(ip,vlan)
);
--
-- Table: log.
--
CREATE TABLE "log" (
"id" serial NOT NULL,
"creation" timestamp DEFAULT current_timestamp,
"class" text,
"entry" text,
"logfile" text
CREATE TABLE log (
id serial,
creation TIMESTAMP DEFAULT now(),
class text,
entry text,
logfile text
);
--
-- Table: node_ip.
--
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")
CREATE TABLE node (
mac macaddr,
switch inet,
port text,
vlan text default '0',
active boolean,
oui varchar(8),
time_first timestamp default now(),
time_recent timestamp default now(),
time_last timestamp default now(),
PRIMARY KEY(mac,switch,port,vlan)
);
--
-- Table: node_monitor.
--
CREATE TABLE "node_monitor" (
"mac" macaddr NOT NULL,
"active" boolean,
"why" text,
"cc" text,
"date" timestamp DEFAULT current_timestamp,
PRIMARY KEY ("mac")
-- Indexes speed things up a LOT
CREATE INDEX idx_node_switch_port_active ON node(switch,port,active);
CREATE INDEX idx_node_switch_port ON node(switch,port);
CREATE INDEX idx_node_switch ON node(switch);
CREATE INDEX idx_node_mac ON node(mac);
CREATE INDEX idx_node_mac_active ON node(mac,active);
-- CREATE INDEX idx_node_oui ON node(oui);
CREATE TABLE node_ip (
mac macaddr,
ip inet,
active boolean,
time_first timestamp default now(),
time_last timestamp default now(),
PRIMARY KEY(mac,ip)
);
--
-- Table: node_nbt.
--
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")
-- Indexing speed ups.
CREATE INDEX idx_node_ip_ip ON node_ip(ip);
CREATE INDEX idx_node_ip_ip_active ON node_ip(ip,active);
CREATE INDEX idx_node_ip_mac ON node_ip(mac);
CREATE INDEX idx_node_ip_mac_active ON node_ip(mac,active);
CREATE TABLE node_monitor (
mac macaddr,
active boolean,
why text,
cc text,
date TIMESTAMP DEFAULT now(),
PRIMARY KEY(mac)
);
--
-- Table: node_wireless.
--
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")
-- node_nbt - Hold Netbios information for each node.
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()
);
--
-- Table: oui.
--
CREATE TABLE "oui" (
"oui" character varying(8) NOT NULL,
"company" text,
PRIMARY KEY ("oui")
-- 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 "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.
--
CREATE TABLE "process" (
"controller" integer NOT NULL,
"device" inet NOT NULL,
"action" text NOT NULL,
"status" text,
"count" integer,
"creation" timestamp DEFAULT current_timestamp
-- 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);
CREATE TABLE oui (
oui varchar(8) PRIMARY KEY,
company text
);
--
-- Table: sessions.
--
CREATE TABLE "sessions" (
"id" character(32) NOT NULL,
"creation" timestamp DEFAULT current_timestamp,
"a_session" text,
PRIMARY KEY ("id")
-- process table - Queue to coordinate between processes in multi-process mode.
CREATE TABLE process (
controller integer not null,
device inet not null,
action text not null,
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)
);
--
-- Table: subnets.
--
CREATE TABLE "subnets" (
"net" cidr NOT NULL,
"creation" timestamp DEFAULT current_timestamp,
"last_discover" timestamp DEFAULT current_timestamp,
PRIMARY KEY ("net")
-- 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
);
--
-- 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")
);
--
-- 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");
-- This table logs login and logout / change requests for users
--
-- Table: device_ip.
--
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");
CREATE TABLE user_log (
entry serial,
username varchar(50),
userip inet,
event text,
details text,
creation TIMESTAMP DEFAULT now()
);
--
-- Table: device_port.
--
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");
CREATE TABLE users (
username varchar(50) PRIMARY KEY,
password text,
creation TIMESTAMP DEFAULT now(),
last_on TIMESTAMP,
port_control boolean DEFAULT false,
ldap boolean DEFAULT false,
admin boolean DEFAULT false,
fullname text,
note text
);
--
-- 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;
--
COMMIT;

View File

@@ -1,3 +0,0 @@
--
-- Created by SQL::Translator::Producer::PostgreSQL
-- Created on Wed Oct 10 14:24:20 2012

View File

@@ -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;
ALTER TABLE node ADD COLUMN vlan text DEFAULT '0' NOT NULL;
ALTER TABLE device_port_vlan ADD COLUMN vlantype text;
COMMIT;

View File

@@ -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;
ALTER TABLE node_wireless ADD COLUMN ssid text DEFAULT '' NOT NULL;
ALTER TABLE node_ip ADD COLUMN dns text;
COMMIT;

View File

@@ -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;
CREATE INDEX device_port_power_idx_ip_port on device_port_power (ip, port);
ALTER TABLE node DROP CONSTRAINT node_pkey;
COMMIT;

View File

@@ -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;
ALTER TABLE admin ADD PRIMARY KEY (job);
ALTER TABLE node_wireless DROP CONSTRAINT node_wireless_pkey;
COMMIT;

View File

@@ -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;
ALTER TABLE node ADD PRIMARY KEY (mac, switch, port, vlan);
ALTER TABLE node ADD COLUMN vlan text DEFAULT '0' NOT NULL;
COMMIT;

View File

@@ -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;
ALTER TABLE node_wireless ADD PRIMARY KEY (mac, ssid);
ALTER TABLE node_wireless ADD COLUMN ssid text DEFAULT '' NOT NULL;
COMMIT;

View File

@@ -1,12 +1,5 @@
BEGIN;
CREATE UNIQUE INDEX jobs_queued ON admin (
action,
coalesce(subaction, '_x_'),
coalesce(device, '255.255.255.255'),
coalesce(port, '_x_')
) WHERE status LIKE 'queued%';
CREATE INDEX device_port_power_idx_ip_port on device_port_power (ip, port);
COMMIT;

View File

@@ -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;
--

View File

@@ -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;
ALTER TABLE topology ADD CONSTRAINT topology_dev1_port1 UNIQUE (dev1, port1);
ALTER TABLE topology ADD CONSTRAINT topology_dev2_port2 UNIQUE (dev2, port2);
ALTER TABLE admin ADD PRIMARY KEY (job);
COMMIT;

View File

@@ -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");

View File

@@ -1,5 +1,5 @@
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;

View File

@@ -1,6 +1,5 @@
BEGIN;
ALTER TABLE device_port ADD COLUMN "is_uplink" bool;
ALTER TABLE device_port ADD COLUMN "is_uplink_admin" bool;
ALTER TABLE node_wireless ADD PRIMARY KEY (mac, ssid);
COMMIT;

View File

@@ -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;
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;

View File

@@ -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;
--

View File

@@ -1,5 +1,10 @@
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;

View File

@@ -1,5 +1,7 @@
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;

View File

@@ -1,5 +1,5 @@
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;

View File

@@ -1,5 +1,6 @@
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;

View File

@@ -1,5 +1,5 @@
BEGIN;
ALTER TABLE device DROP COLUMN snmp_comm_rw;
ALTER TABLE device_ip DROP CONSTRAINT "device_ip_alias";
COMMIT;

View File

@@ -1,9 +1,5 @@
BEGIN;
CREATE TABLE "community" (
"ip" inet NOT NULL,
"snmp_comm_rw" text,
PRIMARY KEY ("ip")
);
-- ALTER TABLE device_port ALTER COLUMN remote_id TYPE bytea USING remote_id::bytea;
COMMIT;

View File

@@ -1,8 +1,5 @@
BEGIN;
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;
-- ALTER TABLE device_port ALTER COLUMN remote_id TYPE text USING remote_id::text;
COMMIT;

View File

@@ -1,6 +1,5 @@
BEGIN;
DROP INDEX IF EXISTS jobs_queued;
ALTER TABLE device ADD COLUMN snmp_comm_rw text;
COMMIT;

View File

@@ -1,6 +1,5 @@
BEGIN;
ALTER TABLE community ADD COLUMN snmp_auth_tag text;
ALTER TABLE device DROP COLUMN snmp_comm_rw;
COMMIT;

View File

@@ -1,6 +1,9 @@
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;

View File

@@ -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;
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;

View File

@@ -1,6 +1,8 @@
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;

View File

@@ -1,8 +1,5 @@
BEGIN;
ALTER TABLE device_port_vlan DROP CONSTRAINT device_port_vlan_pkey;
ALTER TABLE device_port_vlan ADD PRIMARY KEY (ip, port, vlan, native);
DROP INDEX IF EXISTS jobs_queued;
COMMIT;

View File

@@ -1,6 +1,5 @@
BEGIN;
ALTER TABLE oui ADD COLUMN abbrev text;
ALTER TABLE community ADD COLUMN snmp_auth_tag text;
COMMIT;

View File

@@ -1,7 +1,5 @@
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;
UPDATE node SET vlan = '0' WHERE vlan IS NULL;
COMMIT;

View File

@@ -0,0 +1,5 @@
BEGIN;
CREATE INDEX node_ip_idx_ip_active ON node_ip (ip, active);
COMMIT;

View File

@@ -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;

View File

@@ -0,0 +1,5 @@
BEGIN;
ALTER TABLE oui ADD COLUMN abbrev text;
COMMIT;

View File

@@ -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;

View File

@@ -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;
CREATE TABLE "topology" (
"dev1" inet NOT NULL,
"port1" text NOT NULL,
"dev2" inet NOT NULL,
"port2" text NOT NULL
-- Netdisco
-- Database Schema Modifications
-- UPGRADE from 0.94 to 0.95
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;

View File

@@ -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;
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;

View File

@@ -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;
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;

View File

@@ -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;
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;

View File

@@ -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;
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;

View File

@@ -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;
--

View File

@@ -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;
ALTER TABLE node_wireless DROP CONSTRAINT node_wireless_pkey;
ALTER TABLE device_port_ssid ADD COLUMN bssid macaddr;
COMMIT;