Hi,
I have a schema where I have the timestamps
fields defined like this
timestamps(updated_at: false)
I have created a migration to change the type:
def up do
alter table("notifiable_events") do
modify :inserted_at, :date, null: false
end
create unique_index(:notifiable_events, [:invoice_id, :reason, :inserted_at])
end
Now when I change the field definition to
timestamps(updated_at: false, type: :date)
as specified in the documentation, I get an error:
** (UndefinedFunctionError) function :date.from_unix!/2 is undefined (module :date is not available)
code: perform_job(DunningStarter, %{})
stacktrace:
:date.from_unix!(1671025691354039, :microsecond)
(ecto 3.9.2) lib/ecto/repo/schema.ex:965: anonymous fn/2 in Ecto.Repo.Schema.autogenerate_changes/3
(elixir 1.14.0) lib/enum.ex:4249: Enum.flat_map_list/2
What did I miss ?
Edit: as a workaround, I’ve added the autogenerate
option
timestamps(updated_at: false, type: :date, autogenerate: {Date, :utc_today, []})
It works but am I always supposed to add the autogenerate
option ?