Alex Rivera | Logout

PGError: ERROR: relation "table_name" does not exist

Asked 2011-12-05T22:38:14.720
10

I am trying to push a simple app up to heroku and run:

heroku rake db:migrate

But I get the following error:

rake aborted!
PGError: ERROR:  relation "posts" does not exist
:             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 = '"posts"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

My migration looks like this:

class CreatePosts < ActiveRecord::Migration
  def change
    create_table :posts do |t|
      t.string :source
      t.string :tweetid
      t.string :pure
      t.string :media
      t.string :destination
      t.datetime :time
      t.timestamps
    end
  end
end

And, after referring to another SO answer, I have included the following in my Gemfile:

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.1.4'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
  gem 'pg'
end

Thank you in advance for any help!

--- UPDATE ---

The main reason I am confused is that this all works locally, just not when I run the migration on heroku.

Here is the error I get now:

rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)

I have been looking at this question:

Heroku error when launch rails3.1 app missing postgres gem

I am alm

Edit
Report

1 Answer

15
create_table :posts

Didn't you forget the s? The table names should be plural.

answered 2011-12-05T22:43:25.800

Your Answer