If you can afford downtime, follow these steps to upgrade to Rihanna v2.0.0 or higher. This method ensures the required priority column and the new locking index are applied correctly via Ecto migrations.
1. Prepare the Migration
First, upgrade your dependencies to Rihanna v2 using mix. Then, generate a new migration file:
mix ecto.gen.migration
In the generated migration file, use the Rihanna.Migration.Upgrade module to handle the schema changes:
defmodule MyApp.UpgradeRihannaJobs do
use Rihanna.Migration.Upgrade
end
2. Deploy the Changes
To prevent errors during the migration, follow this deployment sequence:
- Stop your application: Jobs cannot be enqueued or processed during the migration.
- Deploy the new code: Deploy the code containing the v2 upgrade, but do not start the application processes.
- Run migrations: Execute
mix ecto.migrate to apply the schema changes. - Restart the application: Start the application now running Rihanna v2.