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.CreateDeviceSubscriberLinks do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
create table(:device_subscriber_links, primary_key: false) do
|
|
add :id, :binary_id, primary_key: true
|
|
|
|
add :organization_id, references(:organizations, type: :binary_id, on_delete: :delete_all),
|
|
null: false
|
|
|
|
add :device_id, references(:devices, type: :binary_id, on_delete: :delete_all), null: false
|
|
|
|
add :gaiia_account_id,
|
|
references(:gaiia_accounts, type: :binary_id, on_delete: :delete_all), null: false
|
|
|
|
add :gaiia_inventory_item_id,
|
|
references(:gaiia_inventory_items, type: :binary_id, on_delete: :nilify_all)
|
|
|
|
add :match_method, :string, null: false
|
|
add :confidence, :string, null: false
|
|
add :subscriber_ip, :string
|
|
add :subscriber_mac, :string
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
create unique_index(:device_subscriber_links, [:device_id, :gaiia_account_id])
|
|
create index(:device_subscriber_links, [:device_id])
|
|
create index(:device_subscriber_links, [:gaiia_account_id])
|
|
create index(:device_subscriber_links, [:organization_id])
|
|
end
|
|
end
|