Skip to content

Commit

Permalink
Rename unit enums
Browse files Browse the repository at this point in the history
  • Loading branch information
adriankumpf committed May 30, 2020
1 parent 0db6d69 commit d45626c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/teslamate/settings/units/length.ex
@@ -1,3 +1,3 @@
defmodule TeslaMate.Settings.Units.Length do
use EctoEnum.Postgres, type: :length, enums: [:km, :mi]
use EctoEnum.Postgres, type: :unit_of_length, enums: [:km, :mi]
end
2 changes: 1 addition & 1 deletion lib/teslamate/settings/units/temperature.ex
@@ -1,3 +1,3 @@
defmodule TeslaMate.Settings.Units.Temperature do
use EctoEnum.Postgres, type: :temperature, enums: [:C, :F]
use EctoEnum.Postgres, type: :unit_of_temperature, enums: [:C, :F]
end
@@ -1,11 +1,18 @@
defmodule TeslaMate.Repo.Migrations.UnitOfLegnthAndTemperature do
use Ecto.Migration

alias TeslaMate.Settings.Units
alias TeslaMate.Repo

import Ecto.Query

defmodule Units.Length do
use EctoEnum.Postgres, type: :length, enums: [:km, :mi]
end

defmodule Units.Temperature do
use EctoEnum.Postgres, type: :temperature, enums: [:C, :F]
end

def up do
[use_imperial_units?] =
from(s in "settings", select: s.use_imperial_units)
Expand Down
15 changes: 15 additions & 0 deletions priv/repo/migrations/20200528173223_rename_unit_enums.exs
@@ -0,0 +1,15 @@
defmodule TeslaMate.Repo.Migrations.RenameUnitEnums do
use Ecto.Migration

def change do
execute(
"ALTER TYPE length RENAME TO unit_of_length",
"ALTER TYPE unit_of_length RENAME TO length"
)

execute(
"ALTER TYPE temperature RENAME TO unit_of_temperature",
"ALTER TYPE unit_of_temperature RENAME TO temperature"
)
end
end

0 comments on commit d45626c

Please sign in to comment.