defmodule Towerops.Repo.Migrations.CreateSnmpInterfaces do
  use Ecto.Migration

  def change do
    create table(:snmp_interfaces, 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 :if_index, :integer, null: false
      add :if_name, :string
      add :if_descr, :string
      add :if_alias, :string
      add :if_type, :integer
      add :if_speed, :bigint
      add :if_phys_address, :string
      add :if_admin_status, :string
      add :if_oper_status, :string
      add :monitored, :boolean, default: true, null: false

      timestamps(type: :utc_datetime)
    end

    create index(:snmp_interfaces, [:snmp_device_id])
    create unique_index(:snmp_interfaces, [:snmp_device_id, :if_index])
  end
end
