Cannot rollback ecto with latest Oban

I get the following error when I attempt to rollback ecto with mix ecto.rollback --all with the following oban versions:

      {:oban, "~> 2.17"},
      {:oban_pro, "~> 1.2", repo: "oban"},
execute "DROP TYPE \"public\".oban_job_state"
** (Postgrex.Error) ERROR 2BP01 (dependent_objects_still_exist) cannot drop type oban_job_state because other objects depend on it

    hint: Use DROP ... CASCADE to drop the dependent objects too.

column state of table oban_jobs_old depends on type oban_job_state
    (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1054: Ecto.Adapters.SQL.raise_sql_call_error/1
    (elixir 1.15.7) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
    (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1161: Ecto.Adapters.SQL.execute_ddl/4
    (ecto_sql 3.11.1) lib/ecto/migration/runner.ex:348: Ecto.Migration.Runner.log_and_execute_ddl/3

Here are my oban migrations:
add_oban_jobs_table:

defmodule MyApp.Migrations.AddObanJobsTable do
  use Ecto.Migration

  def up, do: Oban.Migration.up(version: 12)

  def down, do: Oban.Migration.down(version: 1)
end

add_oban_producers:

defmodule MyApp.Migrations.AddObanProducers do
  use Ecto.Migration

  defdelegate change, to: Oban.Pro.Migrations.Producers
end

add_oban_cron:

defmodule Countdownplus.Repo.Migrations.AddObanCron do
  use Ecto.Migration

  defdelegate change, to: Oban.Pro.Migrations.DynamicCron
end

add_partitioned_oban_jobs_table:

defmodule Countdownplus.Repo.Migrations.AddPartitionedObanJobs do
  use Ecto.Migration

  defdelegate change, to: Oban.Pro.Migrations.DynamicPartitioner
end

For a fresh installation you should use the DynamicPartitioner migration without using the Oban.Migration first. That will create the necessary tables and types by itself.

Thanks. I removed the Oban jobs migration completely and everything checks out. Will be good to update the docs to indicate this for new setups

Removed this:

defmodule MyApp.Migrations.AddObanJobsTable do
  use Ecto.Migration

  def up, do: Oban.Migration.up(version: 12)

  def down, do: Oban.Migration.down(version: 1)
end
1 Like