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

  def change do
    create table(:snmp_memory_pools, 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 :pool_index, :string, null: false
      add :pool_name, :string
      add :pool_type, :string, null: false
      add :total_bytes, :bigint
      add :used_bytes, :bigint
      add :last_checked_at, :utc_datetime
      add :metadata, :map, default: %{}

      timestamps(type: :utc_datetime)
    end

    create index(:snmp_memory_pools, [:snmp_device_id])
    create unique_index(:snmp_memory_pools, [:snmp_device_id, :pool_index])
    create index(:snmp_memory_pools, [:pool_type])
  end
end
