Hi all
When I pass a string to create table as:
create table("countries_code") do
add :iso_num, :integer, primary_key: true
add :iso_alpha_2, :string
timestamps()
end
Then I’ve got following an compile error. Why?
Thanks
Hi all
When I pass a string to create table as:
create table("countries_code") do
add :iso_num, :integer, primary_key: true
add :iso_alpha_2, :string
timestamps()
end
Then I’ve got following an compile error. Why?
Thanks
It looks correct, could you paste error?
table
doesn’t accept strings. It only accepts atoms. Just write your migration as create table(:countries_code) ...
https://github.com/elixir-ecto/ecto/blob/v2.1.3/lib/ecto/migration.ex#L432
It indeed wasn’t supported. We decided to support it, and even give using strings a preference in the docs - it makes it consistent with schemas and queries.
For now this is available only in master. On stable releases you need to use atoms.
What does it mean consistent?
Thanks
Because schema’s and queries take binaries instead of atoms, so this should too.