Programming Phoenix 1.4 Ch. 8 - Postgrex.Error 42P07 (duplicate_table): relation "users" already exists

Having tried everything:

  • Phoenix to v. 1.4.1
  • mix deps.clean
  • coping the source code of the book up to Ch. 8

I still get:

rumbl ∆ mix test
** (Postgrex.Error) ERROR 42P07 (duplicate_table): relation "users" already exists
    (ecto) lib/ecto/adapters/sql.ex:200: Ecto.Adapters.SQL.query!/5
    (ecto) lib/ecto/adapters/postgres.ex:96: anonymous fn/4 in Ecto.Adapters.Postgres.execute_ddl/3
    (elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/adapters/postgres.ex:96: 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:1925: 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

Of course I did ecto.reset too plenty of times.

Anyone that can get me on track again?

3 Likes

MIX_ENV=test mix ecto.reset

21 Likes

That worked.

I had to outcomment the following for some reason.

  socket "/socket", RumblWeb.UserSocket
  # ,
  #   websocket: true,
  #   longpoll: false

Phoenix v1.4.1