Update phx.new generator to use utc_datetime_usec by default

161 views
Skip to first unread message

Kevin Lang

unread,
Jul 14, 2022, 10:02:03 PMJul 14
to phoenix-core
Hello,

One thing I end up doing in most of my apps is changing the default timestamp type over to utc_datetime_usec. This is something recommended by the Postgres team:

https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_timestamp_.28without_time_zone.29

Here is an Ecto core team member expressing regret that the default is not utc_datetime_*, but that it cannot be changed _in Ecto_ as it would be a backwards compatability concern.

https://elixirforum.com/t/why-use-utc-datetime-over-naive-datetime-for-ecto/32532/4

However, I see no reason why we cannot have this generated by default for new apps. Adding the following generated code (by default).

defmodule MyApp.Schema do
  defmacro __using__(_) do
    quote do
      use Ecto.Schema 
      @timestamps_opts [type: :utc_datetime_usec]
   end
  end
end

And then also:
config :myapp, MyApp.Repo, migration_timestamps: [type: :utc_datetime_usec]

Thoughts?

mervielle jahal

unread,
Aug 7, 2022, 7:52:16 PMAug 7
to phoenix-core
LINK UP
Wickr@bowe420
Snap@uk9diaz
Adderral 30mg
Diazepam (Valium)
Zolpidem (Ambien)
Morphine
Ketamine
alprazolam
VALIUM
HEROINE
COCAINE
OXYCODONE
Xanax

Wickr@bowe420
Snap@uk9diaz
Buy Direct and Save Time and Money!
100% Client Satisfaction Guaranteed!

Pedro Assunção

unread,
Aug 18, 2022, 12:33:47 PMAug 18
to phoenix-core
+1
Reply all
Reply to author
Forward
0 new messages