diff --git a/README.md b/README.md index 0c9397ec..5835333d 100644 --- a/README.md +++ b/README.md @@ -430,6 +430,17 @@ a job by assigning a numerical `priority`. priority. Within a particular priority jobs are executed in their scheduled order. +#### Caveats & Guidelines + +The default priority is defined in the jobs table. The least intrusive way to +change it for all jobs is to change the column default: + +```elixir +alter table("oban_jobs") do + modify :priority, :integer, default: 1, from: {:integer, default: 0} +end +``` + ## Unique Jobs The unique jobs feature lets you specify constraints to prevent enqueueing diff --git a/lib/oban/job.ex b/lib/oban/job.ex index c8e65ccc..840fdc59 100644 --- a/lib/oban/job.ex +++ b/lib/oban/job.ex @@ -134,7 +134,7 @@ defmodule Oban.Job do field :attempt, :integer, default: 0 field :attempted_by, {:array, :string} field :max_attempts, :integer, default: 20 - field :priority, :integer, default: 0 + field :priority, :integer field :attempted_at, :utc_datetime_usec field :cancelled_at, :utc_datetime_usec diff --git a/test/oban/job_test.exs b/test/oban/job_test.exs index 7c48627d..7ca5bd6c 100644 --- a/test/oban/job_test.exs +++ b/test/oban/job_test.exs @@ -128,7 +128,7 @@ defmodule Oban.JobTest do end describe "to_map/1" do - @keys_with_defaults ~w(args attempt errors max_attempts meta priority queue state tags)a + @keys_with_defaults ~w(args attempt errors max_attempts meta queue state tags)a defp to_keys(opts) do %{}