Ivan Schneider
Ivan Schneider

Reputation: 1145

PGError: ERROR: relation does not exist (rails 3.1.3)

Migration doesn't create table.

Migration works great, no errors.

$rake db:migrate
==  CreateEvents: migrating ===================================================
-- create_table(:events)
NOTICE:  CREATE TABLE will create implicit sequence "events_id_seq" for serial column "events.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "events_pkey" for table "events"
    -> 0.0120s
==  CreateEvents: migrated (0.0125s) ==========================================

But after that, got an error:

PGError: ERROR:  relation "events" does not exist
LINE 4:              WHERE a.attrelid = '"events"'::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 = '"events"'::regclass
           AND a.attnum > 0 AND NOT a.attisdropped
         ORDER BY a.attnum

And if to look into a database there is no table "events". It's appear in production mode.

Upvotes: 1

Views: 2784

Answers (1)

Volodymyr Rudyi
Volodymyr Rudyi

Reputation: 648

Check if you are performing migrations on production database. By default rake db:migrate uses development DB.

   rake db:migrate RAILS_ENV="production"

Upvotes: 4

Related Questions