prop/priv/repo/migrations/20260408174719_rename_beacon_height_to_ft.exs
Graham McIntire 374f9b106a Beacon height in feet, auto-fill lat/lon from grid
- Rename beacons.height_m to height_ft; migration converts existing
  values (m * 3.28084). Form/list/show labels updated.
- Beacon changeset now fills lat/lon from the grid when they're blank
  (previously only the reverse worked). Lat/lon and grid inputs are no
  longer marked required in the form — enter one side and the other
  populates on blur via phx-change.
2026-04-08 12:55:10 -05:00

16 lines
436 B
Elixir

defmodule Microwaveprop.Repo.Migrations.RenameBeaconHeightToFt do
use Ecto.Migration
# 1 meter = 3.28083989501 feet
@m_to_ft 3.28083989501
def up do
rename table(:beacons), :height_m, to: :height_ft
execute "UPDATE beacons SET height_ft = height_ft * #{@m_to_ft}"
end
def down do
execute "UPDATE beacons SET height_ft = height_ft / #{@m_to_ft}"
rename table(:beacons), :height_ft, to: :height_m
end
end