From d60465971603eb5091c979837943c22c4f9513a0 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Fri, 8 Aug 2014 20:59:30 +0100 Subject: [PATCH] Clean up duplicate node entries on vlan 0 --- Netdisco/Changes | 1 + Netdisco/lib/App/Netdisco/DB.pm | 2 +- .../App-Netdisco-DB-38-39-PostgreSQL.sql | 17 +++++++++++++++++ .../lib/App/Netdisco/Manual/ReleaseNotes.pod | 8 ++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Netdisco/lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-38-39-PostgreSQL.sql diff --git a/Netdisco/Changes b/Netdisco/Changes index 2e061b46..121e6e41 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -27,6 +27,7 @@ * Allow process grouping to work portably again (daemon config watch) * Only start scheduler when schedule config exists * Update to DataTables 1.10.2 for latest Chrome + * Clean up duplicate node entries on vlan 0 2.028013 - 2014-07-31 diff --git a/Netdisco/lib/App/Netdisco/DB.pm b/Netdisco/lib/App/Netdisco/DB.pm index f26ef07a..e0d6a45c 100644 --- a/Netdisco/lib/App/Netdisco/DB.pm +++ b/Netdisco/lib/App/Netdisco/DB.pm @@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces( ); our # try to hide from kwalitee - $VERSION = 38; # schema version used for upgrades, keep as integer + $VERSION = 39; # schema version used for upgrades, keep as integer use Path::Class; use File::Basename; diff --git a/Netdisco/lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-38-39-PostgreSQL.sql b/Netdisco/lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-38-39-PostgreSQL.sql new file mode 100644 index 00000000..686b2f38 --- /dev/null +++ b/Netdisco/lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-38-39-PostgreSQL.sql @@ -0,0 +1,17 @@ +-- clean up node table where vlan = 0 and vlan = +-- +-- DELETE n1.* +-- FROM node n1 INNER JOIN +-- (SELECT mac, switch, port from node +-- GROUP BY mac, switch, port +-- HAVING count(*) > 1) n2 +-- ON n1.mac = n2.mac +-- AND n1.switch = n2.switch +-- AND n1.port = n2.port +-- AND n1.vlan = '0'; + +BEGIN; + +DELETE n1.* FROM node n1 INNER JOIN (SELECT mac, switch, port from node GROUP BY mac, switch, port HAVING count(*) > 1) n2 ON n1.mac = n2.mac AND n1.switch = n2.switch AND n1.port = n2.port AND n1.vlan = '0'; + +COMMIT; diff --git a/Netdisco/lib/App/Netdisco/Manual/ReleaseNotes.pod b/Netdisco/lib/App/Netdisco/Manual/ReleaseNotes.pod index e72330ff..1eff7b67 100644 --- a/Netdisco/lib/App/Netdisco/Manual/ReleaseNotes.pod +++ b/Netdisco/lib/App/Netdisco/Manual/ReleaseNotes.pod @@ -38,6 +38,14 @@ but they are backwards compatible. =head1 2.029000 +=head2 Health Advice + +This release will remove from the database spurious Node (workstation, +printer, etc) entries on vlan 0, which were causing dupliate entries in the +web interface. We advise that you back up the database prior to upgrade: + + /usr/bin/pg_dump -F p --create -f netdisco-pgsql.dump netdisco + =head2 General Notices The configuration item C is now a list (used to be a dictionary).