remove unused plans fields (#59)

This commit is contained in:
Matthew Ryan Dillon 2020-11-21 18:36:56 -07:00 committed by GitHub
parent 404caad2ac
commit 4601a6dc2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -5,18 +5,15 @@ defmodule Planner.Tasks.Plan do
@primary_key {:id, :binary_id, autogenerate: true} @primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id @foreign_key_type :binary_id
schema "plans" do schema "plans" do
field :description, :string
field :finished_at, :naive_datetime field :finished_at, :naive_datetime
field :end, :naive_datetime
field :name, :string field :name, :string
field :start, :naive_datetime
timestamps() timestamps()
end end
def changeset(plan, attrs) do def changeset(plan, attrs) do
plan plan
|> cast(attrs, [:description, :finished_at, :start, :end, :name]) |> cast(attrs, [:name, :finished_at])
|> validate_required([:name]) |> validate_required([:name])
|> update_change(:name, &String.trim/1) |> update_change(:name, &String.trim/1)
end end

View file

@ -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