samsondav / rihanna

Rihanna is a high performance postgres-backed job queue for Elixir
MIT License
439 stars 47 forks source link

JobDispatcher error with custom jobs_table_name #54

Closed onomated closed 5 years ago

onomated commented 5 years ago

This error is returned when attempting to dispatch jobs with a custom jobs_table_name config:

[error] GenServer Rihanna.JobDispatcher terminating
** (ArgumentError) The Rihanna jobs table must be upgraded.

The easiest way to upgrade the database is with Ecto.

Run `mix ecto.gen.migration upgrade_rihanna_jobs` and make your migration look
like this:

    defmodule MyApp.UpgradeRihannaJobs do
      use Rihanna.Migration.Upgrade
    end

Now you can run `mix ecto.migrate`.

    (rihanna) lib/rihanna/migration.ex:267: Rihanna.Migration.raise_upgrade_required!/0
    (rihanna) lib/rihanna/job_dispatcher.ex:31: Rihanna.JobDispatcher.handle_info/2

The check here: https://github.com/samphilipd/rihanna/blob/master/lib/rihanna/migration.ex#L234 is looking for the wrong primary key index. For example, with:

config :rihanna, jobs_table_name: "background_jobs",

The generated primary key index name is background_jobs_pkey vs.rihanna_jobs_pkey resulting in the error above.

lpil commented 5 years ago

Thanks for the report @onomated. I don't have time for this right now but other maintainers may be able to. A PR would also be accepted.

onomated commented 5 years ago

I can take a pass at it. Only challenge may be generating a test for it, but I'll look through the tests you have. Thanks!

samsondav commented 5 years ago

Don't worry too much about a test.