-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c637d46
commit 3f1059b
Showing
14 changed files
with
33 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
defmodule TeslaMate.Repo.Migrations.CreateStates do | ||
use Ecto.Migration | ||
|
||
alias TeslaMate.Log.State.State | ||
|
||
def up do | ||
State.create_type() | ||
def change do | ||
execute "CREATE TYPE states_status AS ENUM ('online', 'offline', 'asleep')", | ||
"DROP TYPE states_status " | ||
|
||
create table(:states) do | ||
add(:state, State.type(), null: false) | ||
add(:state, :states_status, null: false) | ||
|
||
add(:start_date, :utc_datetime, null: false) | ||
add(:end_date, :utc_datetime) | ||
|
||
add(:car_id, references(:cars), null: false) | ||
end | ||
end | ||
|
||
def down do | ||
drop(table(:states)) | ||
execute("DROP TYPE states_status") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
defmodule TeslaMate.Repo.Migrations.AddRangeEnum do | ||
use Ecto.Migration | ||
|
||
alias TeslaMate.Settings.Range | ||
|
||
def change do | ||
Range.create_type() | ||
execute "CREATE TYPE range AS ENUM ('ideal', 'rated')", "DROP TYPE range" | ||
|
||
alter table(:settings) do | ||
add(:preferred_range, Range.type(), default: "rated", null: false) | ||
add :preferred_range, :range, default: "rated", null: false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
defmodule TeslaMate.Repo.Migrations.CostByMinute do | ||
use Ecto.Migration | ||
|
||
defmodule BillingType do | ||
use EctoEnum.Postgres, type: :billing_type, enums: [:per_kwh, :per_minute] | ||
def up do | ||
execute "CREATE TYPE billing_type AS ENUM ('per_kwh', 'per_minute')" | ||
|
||
alter table(:geofences) do | ||
add :billing_type, :billing_type, null: false, default: "per_kwh" | ||
end | ||
|
||
rename table(:geofences), :cost_per_kwh, to: :cost_per_unit | ||
end | ||
|
||
def change do | ||
BillingType.create_type() | ||
def down do | ||
rename table(:geofences), :cost_per_unit, to: :cost_per_kwh | ||
|
||
alter table(:geofences) do | ||
add(:billing_type, BillingType.type(), null: false, default: "per_kwh") | ||
remove :billing_type | ||
end | ||
|
||
rename table(:geofences), :cost_per_kwh, to: :cost_per_unit | ||
execute "DROP TYPE billing_type" | ||
end | ||
end |