Change Timestamps

Learn how to change default options for timestamps.

We'll cover the following...

Change defaults for timestamps

Earlier, we saw how the timestamps method automatically adds inserted_at and updated_at columns to our tables. By default, these will always use Elixir’s NaiveDateTime type, but we’ll can change this globally in our Repo config. Here’s how we could change it to use a UTC timestamp.

config :music_db, MusicDB.Repo, migration_timestamps: [type: :utc_datetime]
...