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

  def change do
    create table(:equipment, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :site_id, references(:sites, type: :binary_id, on_delete: :delete_all), null: false
      add :name, :string, null: false
      add :ip_address, :string, null: false
      add :description, :text
      add :status, :string, null: false, default: "unknown"
      add :last_checked_at, :utc_datetime
      add :last_status_change_at, :utc_datetime
      add :monitoring_enabled, :boolean, default: true, null: false
      add :check_interval_seconds, :integer, default: 300, null: false

      timestamps(type: :utc_datetime)
    end

    create index(:equipment, [:site_id])
    create index(:equipment, [:status])
  end
end
