With the following migration:
defmodule EctoSchema.Repo.Migrations.AddSchemaTable do
use Ecto.Migration
@prefix "v1"
def change do
create table(:person,
prefix: @prefix,
primary_key: false,
comment: "A user that interacts with the app"
) do
add :id, :binary_id,
primary_key: true,
comment: """
The primary unique identifier for the person.
"""
timestamps()
end
end
end
When running mix ecto.migrate, the following errors are thrown:
sntran$ mix ecto.migrate
15:08:00.444 [info] == Running EctoSchema.Repo.Migrations.AddSchemaTable.change/0 forward
15:08:00.444 [info] create table v1.person
** (Postgrex.Error) ERROR 42P01 (undefined_table): relation "person" does not exist
(ecto) lib/ecto/adapters/sql.ex:195: Ecto.Adapters.SQL.query!/5
(ecto) lib/ecto/adapters/postgres.ex:86: anonymous fn/4 in Ecto.Adapters.Postgres.execute_ddl/3
(elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
(ecto) lib/ecto/adapters/postgres.ex:86: Ecto.Adapters.Postgres.execute_ddl/3
(ecto) lib/ecto/migration/runner.ex:98: anonymous fn/2 in Ecto.Migration.Runner.flush/0
(elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
(ecto) lib/ecto/migration/runner.ex:96: Ecto.Migration.Runner.flush/0
(stdlib) timer.erl:181: :timer.tc/2
(ecto) lib/ecto/migration/runner.ex:27: Ecto.Migration.Runner.run/6
(ecto) lib/ecto/migrator.ex:121: Ecto.Migrator.attempt/6
(ecto) lib/ecto/migrator.ex:71: anonymous fn/4 in Ecto.Migrator.do_up/4
(ecto) lib/ecto/adapters/sql.ex:615: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3
(db_connection) lib/db_connection.ex:1274: DBConnection.transaction_run/4
(db_connection) lib/db_connection.ex:1198: DBConnection.run_begin/3
(db_connection) lib/db_connection.ex:789: DBConnection.transaction/3
(ecto) lib/ecto/migrator.ex:244: anonymous fn/4 in Ecto.Migrator.migrate/4
(elixir) lib/enum.ex:1229: Enum."-map/2-lists^map/1-0-"/2
(ecto) lib/mix/tasks/ecto.migrate.ex:84: anonymous fn/4 in Mix.Tasks.Ecto.Migrate.run/2
(elixir) lib/enum.ex:645: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:645: Enum.each/2
Table person should be created under v1 schema.
I believe it has to do with the comment option, as the generated query does not have the schema/prefix to the table. When I removed the comment on create table, it also errors out on the comment of the field.
@sntran A fix is in master. It would be great if you could try it and tell us if everything is ok now.
I can confirm that the fix works. Thank you!
I'm a little sad that this commit did not make 2.1.4, as it was released just 3 days after this. Is there a chance to have this in 2.1.5. I understand that you're all working on getting 2.2 released, but I do need this to run. Otherwise I have to override my phoenix app in the umbrella to use master branch, which it should only depends on phoenix_ecto and not ecto (I have all data related in a separate app).
2.1.5 was published.