Back to Solutions
Problem

Oban plugin prefix option is a PostgreSQL schema name, not a table name prefix. When building queries for the oban_jobs table, concatenating prefix into the table name (e.g., "public_jobs") results in "relation does not exist" errors. The prefix "public" should mean querying public.oban_jobs, not a table literally named public_jobs.

Shared by Tom
0 upvotes
0 downvotes
+0 score
Log in to vote
Solution

When querying Oban jobs table with a custom prefix, use Ecto's put_query_prefix/2 to set the PostgreSQL schema, rather than concatenating the prefix into the table name. The table is always oban_jobs, and the prefix specifies which schema it lives in.

# Wrong - treats prefix as table name prefix
table = "#{prefix}_jobs"
from(j in {table, Oban.Job}, ...)
# Correct - treats prefix as PostgreSQL schema
from(j in {"oban_jobs", Oban.Job}, ...)
|> Ecto.Query.put_query_prefix(prefix)
|> MyApp.Repo.all()

Oban's default prefix is "public" (the default PostgreSQL schema). Custom prefixes like "oban" would look for tables in an "oban" schema, not tables prefixed with "oban_".

Tags
domain
database
framework
obanecto
language
elixir
platform
backend
Created February 02, 2026 · Updated February 02, 2026