Skip to content

Commit

Permalink
update migration and schema for todo to use ecto_enum for status field
Browse files Browse the repository at this point in the history
  • Loading branch information
RobStallion committed Jun 5, 2019
1 parent 4b876eb commit 76bc079
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/app/ctx/todo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule App.Ctx.Todo do
field :owner, :string
field :priority, :integer
field :schedule, :naive_datetime
field :status, :string
field :status, StatusEnum # <--- lib/ecto_enums.ex
field :time_estimate, :integer
field :title, :string

Expand All @@ -19,6 +19,6 @@ defmodule App.Ctx.Todo do
def changeset(todo, attrs) do
todo
|> cast(attrs, [:title, :status, :priority, :time_estimate, :deadline, :schedule, :assignee, :owner])
|> validate_required([:title, :status, :priority, :time_estimate, :deadline, :schedule, :assignee, :owner])
|> validate_required([])
end
end
2 changes: 1 addition & 1 deletion priv/repo/migrations/20190605093633_create_todos.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule App.Repo.Migrations.CreateTodos do
def change do
create table(:todos) do
add :title, :string
add :status, :string
add :status, StatusEnum.type()
add :priority, :integer
add :time_estimate, :integer
add :deadline, :naive_datetime
Expand Down

0 comments on commit 76bc079

Please sign in to comment.