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

  def up do
    create table(:snmp_storage_readings, primary_key: false) do
      add :id, :binary_id, primary_key: true

      add :storage_id, references(:snmp_storage, type: :binary_id, on_delete: :delete_all),
        null: false

      add :used_bytes, :bigint
      add :total_bytes, :bigint
      add :usage_percent, :float
      add :checked_at, :utc_datetime, null: false

      timestamps(type: :utc_datetime, updated_at: false)
    end

    # Create indexes for query performance
    create index(:snmp_storage_readings, [:storage_id])
    create index(:snmp_storage_readings, [:storage_id, :checked_at])
    create index(:snmp_storage_readings, [:checked_at])
  end

  def down do
    drop table(:snmp_storage_readings)
  end
end
