Ecto migration problem ERROR (dependent_objects_still_exist)

134 views
Skip to first unread message

Alex Shneyderman

unread,
Jul 17, 2015, 11:34:47 AM7/17/15
to elixi...@googlegroups.com
defmodule EctoPlay.Repo.Migrations.Init do
  use Ecto.Migration

  def change do
    create table(:report) do
      add :name,  :string
      add :month, :string, size: 7
      timestamps
    end

    create table(:weather) do
      add :city,    :string, size: 40
      add :temp_lo, :integer
      add :temp_hi, :integer
      add :prcp,    :float
      add :report_id, references(:report)
      timestamps
    end
  end

end

I got a migration above:

17:31:57 ecto_play(master) > mix ecto.migrate --repo EctoPlay.Repo


17:32:03.458 [info]  == Running EctoPlay.Repo.Migrations.Init.change/0 forward


17:32:03.458 [info]  create table report


17:32:03.464 [info]  create table weather


17:32:03.470 [info]  == Migrated in 0.1s

17:32:03 ecto_play(master) > mix ecto.rollback --repo EctoPlay.Repo


17:32:05.993 [info]  == Running EctoPlay.Repo.Migrations.Init.change/0 backward


17:32:05.993 [info]  drop table report

** (Postgrex.Error) ERROR (dependent_objects_still_exist): cannot drop table report because other objects depend on it

    (ecto) lib/ecto/adapters/sql/worker.ex:26: Ecto.Adapters.SQL.Worker.query!/4

    (ecto) lib/ecto/adapters/sql.ex:187: Ecto.Adapters.SQL.use_worker/3

    (ecto) lib/ecto/adapters/postgres.ex:59: Ecto.Adapters.Postgres.execute_ddl/3

    _build/dev/lib/ecto_play/priv/repo/migrations/20150709201340_init.exs:5: EctoPlay.Repo.Migrations.Init.change/0

    (stdlib) timer.erl:194: :timer.tc/3

    (ecto) lib/ecto/migration/runner.ex:22: Ecto.Migration.Runner.run/6

    (ecto) lib/ecto/migrator.ex:113: Ecto.Migrator.attempt/6

    (ecto) lib/ecto/migrator.ex:93: anonymous fn/4 in Ecto.Migrator.do_down/4


Is there something special that needs to be done to make weather table drop before report?

José Valim

unread,
Jul 17, 2015, 11:42:44 AM7/17/15
to elixi...@googlegroups.com
I think we would actually need to run those things in reverse order... can you try reverting the order of expressions on "def change" before you rollback and see if it works? If that is the case, can you please open up an issue in ecto?



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/caa9b631-569f-47df-ac1b-05ad6cf29f6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Shneyderman

unread,
Jul 17, 2015, 12:41:54 PM7/17/15
to elixi...@googlegroups.com, jose....@plataformatec.com.br
yeah, reversing order before migration rollback makes it work. 
I will try to update to the latest ecto (I am running v 0.13) and if 
problem still persist will open the issue you asked for.

Thanks,
Alex. 

Alex Shneyderman

unread,
Jul 18, 2015, 4:13:36 AM7/18/15
to elixi...@googlegroups.com, jose....@plataformatec.com.br
Reply all
Reply to author
Forward
0 new messages