# mix.exs
defp deps do
[{:phoenix, "~> 1.1.4"},
{:postgrex, ">= 0.0.0"},
{:phoenix_ecto, "~> 3.0.0-rc"},
{:gettext, "~> 0.9"},
...
]
end
The installed ecto version is "2.0.0-rc.5"
iex(1)> categories = [%{name: "stackoverflow", url: "stackoverflow.com"}]
iex(2)> App.Repo.insert_all App.Category, categories
** (Postgrex.Error) ERROR (not_null_violation): null value in column "inserted_at" violates not-null constraint
table: categories
column: inserted_at
Failing row contains (1, stackoverflow, stackoverflow.com, null, null).
(ecto) lib/ecto/adapters/sql.ex:176: Ecto.Adapters.SQL.query!/5
(ecto) lib/ecto/adapters/sql.ex:350: Ecto.Adapters.SQL.insert_all/8
(ecto) lib/ecto/repo/schema.ex:42: Ecto.Repo.Schema.do_insert_all/6
iex(2)>
From the docs, it seemed the inserted_at
was autogenerated. Should I've to manually do this part?
schema "categories" do
field :name, :string
field :url, :string
timestamps
end
updated_at
now. Fixed it with the one suggested above. – Corpulent