![]() ![]() The issue is that the order of the migrations is important and the :comments table is being created before the :users table, and therefore throwing the error. (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3 (elixir) lib/task/supervised.ex:90: _mfa/2 (ecto_sql) lib/ecto/migrator.ex:323: _maybe_in_transaction/6 (db_connection) lib/db_connection.ex:1427: n_transaction/4 (ecto_sql) lib/ecto/adapters/sql.ex:903: anonymous fn/3 in _or_transaction/4 (ecto_sql) lib/ecto/migrator.ex:324: anonymous fn/3 in _maybe_in_transaction/6 (ecto_sql) lib/ecto/migrator.ex:243: anonymous fn/4 in _up/4 (ecto_sql) lib/ecto/migration/runner.ex:25: /7 (ecto_sql) lib/ecto/migration/runner.ex:116: /0 (ecto_sql) lib/ecto/migration/runner.ex:117: anonymous fn/6 in /0 (ecto_sql) lib/ecto/migration/runner.ex:343: _and_execute_ddl/3 (ecto_sql) lib/ecto/adapters/sql.ex:716: _ddl/4 (ecto_sql) lib/ecto/adapters/sql.ex:629: _sql_call_error/1 ** (Postgrex.Error) ERROR 42P01 (undefined_table) relation "users" does not exist The database for MigrationExample.Repo has been createdĢ0:42:28.605 = Running 20200126013640 .change/0 forwardĢ0:42:28.607 create table comments The database for MigrationExample.Repo has been dropped ![]() Rather than rolling back the previous migration I prefer to ecto.reset, however I encounter this error. I run ecto.migrate with no issue, but now I’d like to add a reference on the :comments table: create table(:comments) doĪdd :users_id, references(:users, on_delete: :nothing) ![]() For example I have a :users table and :comments: create table(:comments) do I’m building out a complex database schema as part of a Phoenix app and I’m running into an error when i make updates to the migration. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |