fix(snmp,db): save FDB to PG (empty inet null), bridge_port + MAC normalize
Made-with: Cursor
This commit is contained in:
@@ -14,6 +14,9 @@ var scanInterfacesSQL string
|
||||
//go:embed sql/003_scan_port_devices.sql
|
||||
var scanPortDevicesSQL string
|
||||
|
||||
//go:embed sql/004_scan_port_devices_bridge_port.sql
|
||||
var scanPortDevicesBridgePortSQL string
|
||||
|
||||
func RunMigrations(db *sql.DB) error {
|
||||
if _, err := db.Exec(initSQL); err != nil {
|
||||
return err
|
||||
@@ -24,5 +27,8 @@ func RunMigrations(db *sql.DB) error {
|
||||
if _, err := db.Exec(scanPortDevicesSQL); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := db.Exec(scanPortDevicesBridgePortSQL); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ create table if not exists scan_port_devices (
|
||||
scan_id text not null references scan_jobs(id) on delete cascade,
|
||||
ip inet not null,
|
||||
if_index int not null,
|
||||
bridge_port int not null default 0,
|
||||
mac text not null,
|
||||
learned_ip inet null,
|
||||
checked_at timestamptz not null
|
||||
@@ -13,3 +14,6 @@ create index if not exists idx_scan_port_devices_scan_ip_if
|
||||
|
||||
create index if not exists idx_scan_port_devices_scan_ip_mac
|
||||
on scan_port_devices (scan_id, ip, mac);
|
||||
|
||||
create index if not exists idx_scan_port_devices_scan_ip_br
|
||||
on scan_port_devices (scan_id, ip, bridge_port);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table scan_port_devices add column if not exists bridge_port int not null default 0;
|
||||
|
||||
create index if not exists idx_scan_port_devices_scan_ip_br
|
||||
on scan_port_devices (scan_id, ip, bridge_port);
|
||||
Reference in New Issue
Block a user