- Create snmp_physical_entities table with migration - Add PhysicalEntity schema with entity_class validation - Support parent/child hierarchy via parent_entity_id - Implement discover_physical_entities/1 in Base profile - Discover chassis, modules, PSUs, fans from ENTITY-MIB - Map entity class integers to string names - Add 10 schema tests and 4 discovery tests - Fix flaky AlertNotifier test with unique names and mailbox clearing
37 lines
1.3 KiB
Elixir
37 lines
1.3 KiB
Elixir
defmodule Towerops.Repo.Migrations.CreateSnmpPhysicalEntities do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
create table(:snmp_physical_entities, primary_key: false) do
|
|
add :id, :binary_id, primary_key: true
|
|
|
|
add :snmp_device_id,
|
|
references(:snmp_devices, type: :binary_id, on_delete: :delete_all),
|
|
null: false
|
|
|
|
add :entity_index, :integer, null: false
|
|
add :entity_class, :string, null: false
|
|
add :description, :string
|
|
add :model_name, :string
|
|
add :serial_number, :string
|
|
add :firmware_revision, :string
|
|
add :hardware_revision, :string
|
|
add :manufacturer_name, :string
|
|
add :position, :integer
|
|
add :last_checked_at, :utc_datetime
|
|
add :metadata, :map, default: %{}
|
|
|
|
# Self-referencing parent relationship for hierarchy
|
|
add :parent_entity_id,
|
|
references(:snmp_physical_entities, type: :binary_id, on_delete: :nilify_all)
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
create index(:snmp_physical_entities, [:snmp_device_id])
|
|
create unique_index(:snmp_physical_entities, [:snmp_device_id, :entity_index])
|
|
create index(:snmp_physical_entities, [:entity_class])
|
|
create index(:snmp_physical_entities, [:parent_entity_id])
|
|
create index(:snmp_physical_entities, [:serial_number])
|
|
end
|
|
end
|