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

  def change do
    create table(:preseem_subscriber_metrics, primary_key: false) do
      add :id, :binary_id, primary_key: true

      add :preseem_access_point_id,
          references(:preseem_access_points, type: :binary_id, on_delete: :delete_all),
          null: false

      add :avg_latency, :float
      add :avg_jitter, :float
      add :avg_loss, :float
      add :avg_throughput, :float
      add :p95_latency, :float
      add :subscriber_count, :integer
      add :recorded_at, :utc_datetime, null: false
    end

    create index(:preseem_subscriber_metrics, [:preseem_access_point_id])
    create index(:preseem_subscriber_metrics, [:recorded_at])
  end
end
