From 4601a6dc2d124b6599b7c252abee4858e9f48863 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 21 Nov 2020 18:36:56 -0700 Subject: [PATCH] remove unused plans fields (#59) --- lib/planner/tasks/plan.ex | 5 +---- ...20201122013313_remove_unused_fields_from_plans.exs | 11 +++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 priv/repo/migrations/20201122013313_remove_unused_fields_from_plans.exs diff --git a/lib/planner/tasks/plan.ex b/lib/planner/tasks/plan.ex index f78a8db..5ddbf09 100644 --- a/lib/planner/tasks/plan.ex +++ b/lib/planner/tasks/plan.ex @@ -5,18 +5,15 @@ defmodule Planner.Tasks.Plan do @primary_key {:id, :binary_id, autogenerate: true} @foreign_key_type :binary_id schema "plans" do - field :description, :string field :finished_at, :naive_datetime - field :end, :naive_datetime field :name, :string - field :start, :naive_datetime timestamps() end def changeset(plan, attrs) do plan - |> cast(attrs, [:description, :finished_at, :start, :end, :name]) + |> cast(attrs, [:name, :finished_at]) |> validate_required([:name]) |> update_change(:name, &String.trim/1) end diff --git a/priv/repo/migrations/20201122013313_remove_unused_fields_from_plans.exs b/priv/repo/migrations/20201122013313_remove_unused_fields_from_plans.exs new file mode 100644 index 0000000..aae68b0 --- /dev/null +++ b/priv/repo/migrations/20201122013313_remove_unused_fields_from_plans.exs @@ -0,0 +1,11 @@ +defmodule Planner.Repo.Migrations.RemoveUnusedFieldsFromPlans do + use Ecto.Migration + + def change do + alter table(:plans) do + remove(:start) + remove(:end) + remove(:description) + end + end +end