From 76bc079d8d579bea4b6e013ab53858c973ffc103 Mon Sep 17 00:00:00 2001 From: Robert Francis Date: Wed, 5 Jun 2019 11:40:19 +0100 Subject: [PATCH] update migration and schema for todo to use ecto_enum for status field #1 --- lib/app/ctx/todo.ex | 4 ++-- priv/repo/migrations/20190605093633_create_todos.exs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/app/ctx/todo.ex b/lib/app/ctx/todo.ex index 9448b64..d29cc08 100644 --- a/lib/app/ctx/todo.ex +++ b/lib/app/ctx/todo.ex @@ -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 @@ -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 diff --git a/priv/repo/migrations/20190605093633_create_todos.exs b/priv/repo/migrations/20190605093633_create_todos.exs index 5a54ef0..f78de79 100644 --- a/priv/repo/migrations/20190605093633_create_todos.exs +++ b/priv/repo/migrations/20190605093633_create_todos.exs @@ -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