** (Mix) Unknown type `:timestamp` given to generator. The supported types are: array, binary, boolean, date, decimal, enum, float, integer, map, naive_datetime, naive_datetime_usec, references, string, text, time, time_usec, utc_datetime, utc_datetime_usec, uuid
Any idea what option from the error message options should I choose so the format is compatible with the Postgres’s timestamp ? In other words which should I use so they are the same as inserted_at columns that are automatically created by Phoenix?
Yes, :naive_datetime. You can see the default timestamp applied (when using the timestamp() function in your schema) on the schema attributes doc here (in the @timestamp_opts) and in the migrations function here
It seems that I should use utc_datetime instead of your suggestion :naive_datetime, or?
Source:
Definitely use :utc_datetime_*. In hindsight, we wish we made that the default in Ecto but now we can’t due to backwards compatibility (and there are no plans for Ecto 4)
This seems to be quite polarizing topic. It would be great to know the opinion of Phoenix veterans what version they use in their projects.
You’ve asked to get what Ecto is putting by default, and that’s :naive_datetime. I don’t have any idea what you’re trying to do with it. What you actually need depends on requirements.
From what i know, :naive_datetime are there for backwards compatibility (hence the defaults). I only use utc_* in my projects (because i need UTC, but also because i don’t see a reason to use :naive_* unless having a good reason to do so).
With that said, if you’re just working towards a pet project to train yourself, i wouldn’t bother with it at the moment (the default will do the job just fine, unless you are actually going to work with timestamps that requires timezone stuff).