insert_all does not create auto generated inserted_at with ecto 2.0
The Ecto.Schema.timestamps/1 function defines the inserted_at
and updated_at
columns. There is a function with the same name in the migrations.
You can either set this at the database level by using:
alter table(:categories) do
modify :inserted_at, :utc_datetime, default: fragment("NOW()")
end
Or you can set it in your map:
categories = [%{name: "stackoverflow", url: "stackoverflow.com", inserted_at: Ecto.DateTime.utc}]
Whichever solution you pick, you will likely have to do the same for updated_at
.
If you don't want to track the timestamps then you can remove timestamps
from your schema and drop the columns in a migration (or if you have not committed the migration to version control, just delete the timestamps
function).