Create table does not except string

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

1 Like

It looks correct, could you paste error?

1 Like

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

1 Like

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.

https://github.com/elixir-ecto/ecto/pull/1965

4 Likes

What does it mean consistent?

Thanks

1 Like

Because schema’s and queries take binaries instead of atoms, so this should too. :slight_smile:

1 Like