rename device_groups to host_groups in netmap positions
This commit is contained in:
@@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces(
|
|||||||
);
|
);
|
||||||
|
|
||||||
our # try to hide from kwalitee
|
our # try to hide from kwalitee
|
||||||
$VERSION = 50; # schema version used for upgrades, keep as integer
|
$VERSION = 51; # schema version used for upgrades, keep as integer
|
||||||
|
|
||||||
use Path::Class;
|
use Path::Class;
|
||||||
use File::ShareDir 'dist_dir';
|
use File::ShareDir 'dist_dir';
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ __PACKAGE__->table("netmap_positions");
|
|||||||
__PACKAGE__->add_columns(
|
__PACKAGE__->add_columns(
|
||||||
"id",
|
"id",
|
||||||
{ data_type => "integer", is_nullable => 0, is_auto_increment => 1 },
|
{ data_type => "integer", is_nullable => 0, is_auto_increment => 1 },
|
||||||
"device_groups",
|
"device",
|
||||||
|
{ data_type => "inet", is_nullable => 1 },
|
||||||
|
"host_groups",
|
||||||
|
{ data_type => "text[]", is_nullable => 0 },
|
||||||
|
"locations",
|
||||||
{ data_type => "text[]", is_nullable => 0 },
|
{ data_type => "text[]", is_nullable => 0 },
|
||||||
"vlan",
|
"vlan",
|
||||||
{ data_type => "integer", is_nullable => 0, default => 0 },
|
{ data_type => "integer", is_nullable => 0, default => 0 },
|
||||||
@@ -19,7 +23,4 @@ __PACKAGE__->add_columns(
|
|||||||
|
|
||||||
__PACKAGE__->set_primary_key("id");
|
__PACKAGE__->set_primary_key("id");
|
||||||
|
|
||||||
__PACKAGE__->add_unique_constraint(
|
|
||||||
"netmap_positions_device_groups_vlan_key" => [qw/device_groups vlan/]);
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ ajax '/ajax/data/device/netmappositions' => require_login sub {
|
|||||||
return unless scalar keys %clean;
|
return unless scalar keys %clean;
|
||||||
|
|
||||||
my $posrow = schema('netdisco')->resultset('NetmapPositions')->find({
|
my $posrow = schema('netdisco')->resultset('NetmapPositions')->find({
|
||||||
device_groups => \[ '= ?', [device_groups => [sort @hgrplist]] ],
|
host_groups => \[ '= ?', [host_groups => [sort @hgrplist]] ],
|
||||||
vlan => ($vlan || 0)});
|
vlan => ($vlan || 0)});
|
||||||
if ($posrow) {
|
if ($posrow) {
|
||||||
$posrow->update({ positions => to_json(\%clean) });
|
$posrow->update({ positions => to_json(\%clean) });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
schema('netdisco')->resultset('NetmapPositions')->create({
|
schema('netdisco')->resultset('NetmapPositions')->create({
|
||||||
device_groups => [sort @hgrplist],
|
host_groups => [sort @hgrplist],
|
||||||
vlan => ($vlan || 0),
|
vlan => ($vlan || 0),
|
||||||
positions => to_json(\%clean),
|
positions => to_json(\%clean),
|
||||||
});
|
});
|
||||||
@@ -167,8 +167,8 @@ ajax '/ajax/data/device/netmap' => require_login sub {
|
|||||||
# DEVICES (NODES)
|
# DEVICES (NODES)
|
||||||
|
|
||||||
my $posrow = schema('netdisco')->resultset('NetmapPositions')->find({
|
my $posrow = schema('netdisco')->resultset('NetmapPositions')->find({
|
||||||
device_groups => \[ '= ?',
|
host_groups => \[ '= ?',
|
||||||
[device_groups => [$mapshow eq 'all' ? '__ANY__' : (sort @hgrplist)]] ],
|
[host_groups => [$mapshow eq 'all' ? '__ANY__' : (sort @hgrplist)]] ],
|
||||||
vlan => ($vlan || 0)});
|
vlan => ($vlan || 0)});
|
||||||
my $pos_for = from_json( $posrow ? $posrow->positions : '{}' );
|
my $pos_for = from_json( $posrow ? $posrow->positions : '{}' );
|
||||||
|
|
||||||
|
|||||||
13
share/schema_versions/App-Netdisco-DB-50-51-PostgreSQL.sql
Normal file
13
share/schema_versions/App-Netdisco-DB-50-51-PostgreSQL.sql
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE netmap_positions DROP CONSTRAINT "netmap_positions_device_groups_vlan_key";
|
||||||
|
|
||||||
|
ALTER TABLE netmap_positions RENAME COLUMN device_groups TO host_groups;
|
||||||
|
|
||||||
|
ALTER TABLE netmap_positions ALTER COLUMN host_groups SET DEFAULT '{}';
|
||||||
|
|
||||||
|
ALTER TABLE netmap_positions ADD COLUMN "device" inet;
|
||||||
|
|
||||||
|
ALTER TABLE netmap_positions ADD COLUMN "locations" text[] DEFAULT '{}' NOT NULL;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
Reference in New Issue
Block a user