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

  def change do
    create table(:snmp_processors, 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 :processor_index, :string, null: false
      add :description, :string
      add :processor_type, :string, null: false
      add :load_percent, :float
      add :last_checked_at, :utc_datetime
      add :metadata, :map, default: %{}

      timestamps(type: :utc_datetime)
    end

    create index(:snmp_processors, [:snmp_device_id])
    create unique_index(:snmp_processors, [:snmp_device_id, :processor_index])
  end
end
