Elixir Ecto database create failed on SQL_ASCII
I was just about to create my first database with Ecto migrations in Phoenix, so I ran the create command.
But I ran into the following PostgreSQL template issue.
** (Mix) The database for Imageyard.Repo couldn't be created, reason given: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) HINT: Use the same encoding as in the template database, or use template0 as template.
I remembered having the same problem with my rails application on my dev environment so you just have to do what the error is suggesting.
Specify the template yourself by adding
template: "template0" into your dev and test database config files.
# The files are located under config directory at # config/dev.exs # config/test.exs config :appname, Appname.Repo, adapter: Ecto.Adapters.Postgres, username: "developer", password: "password", database: "appname_dev", template: "template0", size: 10
mix ecto.create again and you have your first database created with Ecto – exciting.
Thank you for reading! Did you like the article? Send me a comment.