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
