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

  def up do
    # Note: TimescaleDB features removed due to Apache license restrictions
    # Using standard PostgreSQL table instead
    create table(:snmp_sensor_readings) do
      add :sensor_id, references(:snmp_sensors, type: :binary_id, on_delete: :delete_all),
        null: false

      add :value, :float
      add :status, :string, null: false
      add :checked_at, :utc_datetime, null: false

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

    # Create indexes for query performance
    create index(:snmp_sensor_readings, [:sensor_id])
    create index(:snmp_sensor_readings, [:sensor_id, :checked_at])
    create index(:snmp_sensor_readings, [:status])
    create index(:snmp_sensor_readings, [:checked_at])
  end

  def down do
    drop table(:snmp_sensor_readings)
  end
end
