When the Oban queue backs up, the 60-second uniqueness window expires and duplicate jobs stack up per device. Switch to period: :infinity so only one poll/monitor job exists per device at any time. Add replace option to supersede stale scheduled jobs with updated scheduled_at. Remove :executing from unique states so self-scheduling works while the current job runs. Set max_attempts: 1 since retrying stale polls is pointless. Also fix all credo --strict issues across the codebase.
32 lines
1.1 KiB
Elixir
32 lines
1.1 KiB
Elixir
defmodule Towerops.Repo.Migrations.CreateWirelessClients do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
create table(:wireless_clients, primary_key: false) do
|
|
add :id, :binary_id, primary_key: true
|
|
add :device_id, references(:devices, type: :binary_id, on_delete: :delete_all), null: false
|
|
|
|
add :organization_id, references(:organizations, type: :binary_id, on_delete: :delete_all),
|
|
null: false
|
|
|
|
add :mac_address, :string, null: false
|
|
add :ip_address, :string
|
|
add :hostname, :string
|
|
add :signal_strength, :integer
|
|
add :snr, :integer
|
|
add :distance, :integer
|
|
add :tx_rate, :integer
|
|
add :rx_rate, :integer
|
|
add :uptime_seconds, :integer
|
|
add :last_seen_at, :utc_datetime, null: false
|
|
add :metadata, :map, default: %{}
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
create unique_index(:wireless_clients, [:device_id, :mac_address])
|
|
create index(:wireless_clients, [:device_id])
|
|
create index(:wireless_clients, [:mac_address])
|
|
create index(:wireless_clients, [:organization_id])
|
|
end
|
|
end
|