abueloshika
Advice on clearing Ecto.Date and Ecto.Time deprecations
As I’ve mentioned before I’m currently working on a project that has some gnarly deprecation issues. Being new to Elixir (and development in general) it is proving to be a great learning opportunity but I am very stuck on something.
I have a model like:
schema "person" do
field :date_of_birth, Ecto.Date
field :appointment_time, Ecto.Time
timestamps()
@required_fields ~w(appointment_time)
@optional_fields ~w(date_of_birth)
def changeset(model, params \\ :empty) do
model
|> cast(params, @required_fields, @optional_fields)
end
date_of_birth goes to a date column in the DB and appointment_time to a time_without_timezone. appointment_time’s associated param is a string formatted like “00:00:00”.
I am utterly confused about how to replace these types properly after their deprecations. My current implementation as per my understanding of the docs:
field :date_of_birth, :date
field :appointment_time, :utc_datetime
This is clearly incorrect because the appointment_time fails the cast type validation. I have many examples of this particular requirement throughout the project so I’d really like to understand the correct methodology at play.
Most Liked
abueloshika
Sometimes typing this stuff out sharpens your mind.
My problem was that I should have been using
field :appointment_time, :time
not utc_datetime
Move along people, nothing to see here. Guy definitely make a post about something he was struggling with for an hour then fixed 30 seconds after posting
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









