Search code examples
elixirphoenix-frameworkecto

When using datetime -- warning, when using utc_datetime instead -- exception


When generating a column of type "datetime" I get a warning

the :datetime type in migrations is deprecated,
  please use :utc_datetime or :naive_datetime instead

However, when I replace with the type "utc_datetime", I get an exception:

** (Mix) Unknown type `utc_datetime` given to generator

Solution

  • While :datetime has been deprecated by Ecto like the warning says, the latest version of Phoenix, 1.2.1, was released on 12 Aug 2016, before the Phoenix generators were updated to use the new datetime types on 18 Sep 2016. So, until Phoenix releases 1.2.2 or 1.3.0, you'll have to use datetime in the generators and manually change the types in the generated migration and schema, or use the unreleased version of Phoenix directly from the master branch of its git repo.