- 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.
16 lines
436 B
Elixir
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
|