Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PGError: ERROR: relation "delayed_jobs" does not exist (Postgresql, rails 3.04, delayed_job error)

I did rake db:create and then rake db:migrate and ran into this error.

rake aborted!
PGError: ERROR:  relation "delayed_jobs" does not exist
LINE 4:              WHERE a.attrelid = '"delayed_jobs"'::regclass
                                        ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"delayed_jobs"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
like image 792
sent-hil Avatar asked Jan 19 '23 02:01

sent-hil


1 Answers

Your query is casting "delayed_jobs" to a regclass, which translates the name of a table to PostgreSQL's internal ID number. If the cast can't be made you get the error: SELECT 'foo'::regclass; ERROR: relation "foo" does not exist

Presumably your migrate script should be catching this error and creating the table (maybe the problem is it already thinks it has done so).

P.S. - The title of your question isn't helpful. PostgreSQL doesn't have a problem working with "delayed_job". Not only don't you have a table "delayed_job" but the problem is clearly with Rail's create or migrate scripts.

like image 120
Richard Huxton Avatar answered Jan 31 '23 11:01

Richard Huxton