From 4f57a4d30aa03d59a1ba328c67478f597a1e16d0 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 18 Apr 2020 16:50:49 +0100 Subject: [PATCH] rename ports column in device table to be num_ports --- Changes | 8 +++++++- lib/App/Netdisco/DB.pm | 2 +- lib/App/Netdisco/DB/Result/Device.pm | 2 +- lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm | 4 +++- .../schema_versions/App-Netdisco-DB-61-62-PostgreSQL.sql | 5 +++++ 5 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 share/schema_versions/App-Netdisco-DB-61-62-PostgreSQL.sql diff --git a/Changes b/Changes index f5681c75..c4c07128 100644 --- a/Changes +++ b/Changes @@ -1,8 +1,14 @@ +2.045002 - 2020-04-18 + + [BUG FIXES] + + * rename ports column in device table to be num_ports + 2.045001 - 2020-04-18 [BUG FIXES] - * restore port column in device table, needed for discovery + * restore ports column in device table to fix discover bug 2.045000 - 2020-04-15 diff --git a/lib/App/Netdisco/DB.pm b/lib/App/Netdisco/DB.pm index 18abc8d2..e75f784a 100644 --- a/lib/App/Netdisco/DB.pm +++ b/lib/App/Netdisco/DB.pm @@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces( ); our # try to hide from kwalitee - $VERSION = 61; # schema version used for upgrades, keep as integer + $VERSION = 62; # schema version used for upgrades, keep as integer use Path::Class; use File::ShareDir 'dist_dir'; diff --git a/lib/App/Netdisco/DB/Result/Device.pm b/lib/App/Netdisco/DB/Result/Device.pm index bd1c8f8b..78d505fd 100644 --- a/lib/App/Netdisco/DB/Result/Device.pm +++ b/lib/App/Netdisco/DB/Result/Device.pm @@ -35,7 +35,7 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "layers", { data_type => "varchar", is_nullable => 1, size => 8 }, - "ports", + "num_ports", { data_type => "integer", is_serializable => 0, is_nullable => 1 }, "mac", { data_type => "macaddr", is_nullable => 1 }, diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index cb5fd71d..5927147e 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -35,7 +35,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { my @properties = qw/ snmp_ver description uptime name - layers ports mac + layers mac ps1_type ps2_type ps1_status ps2_status fan slots vendor os os_ver @@ -51,7 +51,9 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { $device->set_column( contact => Encode::decode('UTF-8', $snmp->contact) ); $device->set_column( location => Encode::decode('UTF-8', $snmp->location) ); + $device->set_column( num_ports => $snmp->ports ); $device->set_column( snmp_class => $snmp->class ); + $device->set_column( last_discover => \'now()' ); schema('netdisco')->txn_do(sub { diff --git a/share/schema_versions/App-Netdisco-DB-61-62-PostgreSQL.sql b/share/schema_versions/App-Netdisco-DB-61-62-PostgreSQL.sql new file mode 100644 index 00000000..e2ab428b --- /dev/null +++ b/share/schema_versions/App-Netdisco-DB-61-62-PostgreSQL.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE device RENAME COLUMN ports TO num_ports; + +COMMIT;