Ecto: ERROR 42601 (syntax_error): syntax error at or near "("

Created on 9 Mar 2018  路  3Comments  路  Source: elixir-ecto/ecto

Environment

  • Elixir version: 1.5.3
  • Database and version (PostgreSQL):10.1
  • Ecto version (mix deps): 2.1
  • Database adapter and version (mix deps):
  • Operating system: macOs high sierra

Current behavior

my code is :

defmodule TrangellUsersService.Repo.Migrations.UsersInfo do
  use Ecto.Migration

  def change do
    create table(:usersinfo, prefix: "acdeep_of_trangell", primary_key: false) do
        add :id, :uuid, primary_key: true
        add :full_name, :string, size: 40, null: false
        add :email, :string, size: 70, null: false, unique: true
        add :password, :string, size: 150, null: false
        add :password_hash, :string, size: 150, null: false
        add :last_ip, :string, size: 20, null: false
        add :last_token, :text, default: "0", null: false
        add :group_acl, :map, size: 50, null: false
        add :company_name, :string, size: 40
        add :site_address, :string, size: 40
        add :language, :string, size: 3, null: false
        add :country, :string, size: 20, null: false
        add :state, :string, size: 20, null: false
        add :age, :integer, size: 3 , default: 0, null: false

        timestamps()
    end

    create index(:usersinfo, [:id], prefix: "acdeep_of_trangell", concurrently: true, name: :index_of_users_uuid, unique: true)
    create index(:usersinfo, [:email], prefix: "acdeep_of_trangell", concurrently: true, name: :index_of_users_unique_email, unique: true)
  end
end

my error :

[info] == Running TrangellUsersService.Repo.Migrations.UsersInfo.change/0 forward
[info] create table acdeep_of_trangell.usersinfo
** (Postgrex.Error) ERROR 42601 (syntax_error): syntax error at or near "("
    (ecto) lib/ecto/adapters/sql.ex:200: Ecto.Adapters.SQL.query!/5
    (ecto) lib/ecto/adapters/postgres.ex:85: anonymous fn/4 in Ecto.Adapters.Postgres.execute_ddl/3
    (elixir) lib/enum.ex:1829: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/adapters/postgres.ex:85: Ecto.Adapters.Postgres.execute_ddl/3
    (ecto) lib/ecto/migration/runner.ex:104: anonymous fn/2 in Ecto.Migration.Runner.flush/0
    (elixir) lib/enum.ex:1829: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/migration/runner.ex:102: Ecto.Migration.Runner.flush/0
    (stdlib) timer.erl:181: :timer.tc/2

Most helpful comment

The size option is not allowed on integer for Postgres. You can see the generated sql by passing the --log-sql flag. We also opened up an issue to improve the error report if possible on Postgres, thank you.

All 3 comments

The size option is not allowed on integer for Postgres. You can see the generated sql by passing the --log-sql flag. We also opened up an issue to improve the error report if possible on Postgres, thank you.

To Force migrations to run outside of a transaction @disable_ddl_transaction true

https://hexdocs.pm/ecto/Ecto.Migration.html#module-transactions

thank you @josevalim , This error is very difficult for understanding.

Was this page helpful?
0 / 5 - 0 ratings