After picking a site in the coverage form, a new optional dropdown lets the user attach the coverage to one of the devices at that site. The dropdown reloads on every site change. If the site has no devices yet, a hint replaces it. Schema: nullable device_id FK on coverages (on_delete: nilify_all so deleting a device leaves the coverage standing). Filtered by both site_id and organization_id when loading the dropdown options. Show page lists the attached device by name (or IP) when set.
14 lines
467 B
Elixir
14 lines
467 B
Elixir
defmodule Towerops.Repo.Migrations.AddDeviceIdToCoverages do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
alter table(:coverages) do
|
|
# Optional FK to a device at the parent site. The coverage represents
|
|
# the radio mounted on this device's tower. nil means "no specific
|
|
# device" (e.g. a planning study).
|
|
add :device_id, references(:devices, type: :binary_id, on_delete: :nilify_all)
|
|
end
|
|
|
|
create index(:coverages, [:device_id])
|
|
end
|
|
end
|