0

I tried to deploy my app to Heroku, but it closed out with an error. Looking at the logs it says:

[3] ! Unable to load application:ActiveRecord::StatementInvalid:PG::UndefinedTable: ERROR:  relation "comments" does not exist

Full log:

2016-03-03T19:50:05.208825+00:00 app[web.1]:                                           ^
2016-03-03T19:50:05.208826+00:00 app[web.1]: :               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2016-03-03T19:50:05.208827+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2016-03-03T19:50:05.208828+00:00 app[web.1]:                 FROM pg_attribute a LEFT JOIN pg_attrdef d
2016-03-03T19:50:05.208829+00:00 app[web.1]:                   ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2016-03-03T19:50:05.208829+00:00 app[web.1]:                WHERE a.attrelid = '"comments"'::regclass
2016-03-03T19:50:05.208830+00:00 app[web.1]:                  AND a.attnum > 0 AND NOT a.attisdropped
2016-03-03T19:50:05.208830+00:00 app[web.1]:                ORDER BY a.attnum
2016-03-03T19:50:05.208831+00:00 app[web.1]: 
2016-03-03T19:50:05.208839+00:00 app[web.1]:                                           ^
2016-03-03T19:50:05.208839+00:00 app[web.1]: :               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2016-03-03T19:50:05.208840+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2016-03-03T19:50:05.208837+00:00 app[web.1]: [3] ! Unable to load application: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "comments" does not exist
2016-03-03T19:50:05.208838+00:00 app[web.1]: LINE 5:                WHERE a.attrelid = '"comments"'::regclass
2016-03-03T19:50:05.208841+00:00 app[web.1]:                WHERE a.attrelid = '"comments"'::regclass
2016-03-03T19:50:05.208849+00:00 app[web.1]: LINE 5:                WHERE a.attrelid = '"comments"'::regclass
2016-03-03T19:50:05.208848+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `async_exec': PG::UndefinedTable: ERROR:  relation "comments" does not exist (ActiveRecord::StatementInvalid)
2016-03-03T19:50:05.208851+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2016-03-03T19:50:05.208840+00:00 app[web.1]:                 FROM pg_attribute a LEFT JOIN pg_attrdef d
2016-03-03T19:50:05.208842+00:00 app[web.1]:                ORDER BY a.attnum
2016-03-03T19:50:05.208850+00:00 app[web.1]:                                           ^
2016-03-03T19:50:05.208841+00:00 app[web.1]:                   ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2016-03-03T19:50:05.208842+00:00 app[web.1]:                  AND a.attnum > 0 AND NOT a.attisdropped
2016-03-03T19:50:05.208852+00:00 app[web.1]:                 FROM pg_attribute a LEFT JOIN pg_attrdef d
2016-03-03T19:50:05.208852+00:00 app[web.1]:                   ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2016-03-03T19:50:05.208854+00:00 app[web.1]:                ORDER BY a.attnum
2016-03-03T19:50:05.208850+00:00 app[web.1]: :               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2016-03-03T19:50:05.208853+00:00 app[web.1]:                  AND a.attnum > 0 AND NOT a.attisdropped
2016-03-03T19:50:05.208853+00:00 app[web.1]:                WHERE a.attrelid = '"comments"'::regclass

I have been looking through my schema.rb, but I can't spot any issues. My schema.rb is:

ActiveRecord::Schema.define(version: 20160301035526) do

  create_table "activities", force: true do |t|
    t.integer  "trackable_id"
    t.string   "trackable_type"
    t.integer  "owner_id"
    t.string   "owner_type"
    t.string   "key"
    t.text     "parameters"
    t.integer  "recipient_id"
    t.string   "recipient_type"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "activities", ["owner_id", "owner_type"], name: "index_activities_on_owner_id_and_owner_type"
  add_index "activities", ["recipient_id", "recipient_type"], name: "index_activities_on_recipient_id_and_recipient_type"
  add_index "activities", ["trackable_id", "trackable_type"], name: "index_activities_on_trackable_id_and_trackable_type"

  create_table "comments", force: true do |t|
    t.string   "title",            limit: 50, default: ""
    t.text     "comment"
    t.integer  "commentable_id"
    t.string   "commentable_type"
    t.integer  "user_id"
    t.string   "role",                        default: "comments"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.text     "comment_html"
  end

  add_index "comments", ["commentable_id"], name: "index_comments_on_commentable_id"
  add_index "comments", ["commentable_type"], name: "index_comments_on_commentable_type"
  add_index "comments", ["user_id"], name: "index_comments_on_user_id"

  create_table "events", force: true do |t|
    t.string   "name"
    t.datetime "when"
    t.integer  "user_id"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "cached_votes_up", default: 0
    t.integer  "comments_count",  default: 0
  end

  add_index "events", ["cached_votes_up"], name: "index_events_on_cached_votes_up"
  add_index "events", ["comments_count"], name: "index_events_on_comments_count"
  add_index "events", ["user_id"], name: "index_events_on_user_id"

  create_table "follows", force: true do |t|
    t.integer  "followable_id",                   null: false
    t.string   "followable_type",                 null: false
    t.integer  "follower_id",                     null: false
    t.string   "follower_type",                   null: false
    t.boolean  "blocked",         default: false, null: false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "follows", ["followable_id", "followable_type"], name: "fk_followables"
  add_index "follows", ["follower_id", "follower_type"], name: "fk_follows"

  create_table "friendly_id_slugs", force: true do |t|
    t.string   "slug",                      null: false
    t.integer  "sluggable_id",              null: false
    t.string   "sluggable_type", limit: 50
    t.string   "scope"
    t.datetime "created_at"
  end

  add_index "friendly_id_slugs", ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true
  add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type"
  add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id"
  add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type"

  create_table "musics", force: true do |t|
    t.string   "url"
    t.string   "name"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "posts", force: true do |t|
    t.text     "content",                     null: false
    t.integer  "user_id"
    t.string   "attachment"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "cached_votes_up", default: 0
    t.integer  "comments_count",  default: 0
    t.text     "content_html"
  end

  add_index "posts", ["cached_votes_up"], name: "index_posts_on_cached_votes_up"
  add_index "posts", ["comments_count"], name: "index_posts_on_comments_count"
  add_index "posts", ["user_id"], name: "index_posts_on_user_id"

  create_table "users", force: true do |t|
    t.string   "name",                   default: "",     null: false
    t.string   "email",                  default: "",     null: false
    t.string   "encrypted_password",     default: "",     null: false
    t.string   "about"
    t.string   "avatar"
    t.string   "cover"
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          default: 0,      null: false
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
    t.string   "confirmation_token"
    t.datetime "confirmed_at"
    t.datetime "confirmation_sent_at"
    t.datetime "created_at",                              null: false
    t.datetime "updated_at",                              null: false
    t.string   "***",                    default: "male", null: false
    t.string   "location"
    t.date     "dob"
    t.string   "phone_number"
    t.integer  "posts_count",            default: 0,      null: false
    t.string   "slug"
  end

  add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
  add_index "users", ["email"], name: "index_users_on_email", unique: true
  add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
  add_index "users", ["slug"], name: "index_users_on_slug", unique: true

  create_table "votes", force: true do |t|
    t.integer  "votable_id"
    t.string   "votable_type"
    t.integer  "voter_id"
    t.string   "voter_type"
    t.boolean  "vote_flag"
    t.string   "vote_scope"
    t.integer  "vote_weight"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "votes", ["votable_id", "votable_type", "vote_scope"], name: "index_votes_on_votable_id_and_votable_type_and_vote_scope"
  add_index "votes", ["voter_id", "voter_type", "vote_scope"], name: "index_votes_on_voter_id_and_voter_type_and_vote_scope"

end

Can anyone point me in the right direction on debugging this?

Justin Howard
  • 5,504
  • 1
  • 21
  • 48
  • 1
    possible duplicate: http://stackoverflow.com/a/34321825/981616 – uday Mar 03 '16 at 21:04
  • The schema is just a snapshot of what your database should like when all the migrations are done. You actually have to run the migrations on Heroku. `heroku run rake db:migrate` – max Mar 03 '16 at 21:37
  • It took a little while, but once I made a new clone, and ran: heroku run rake db:migrate Its working now. Thanks! – Nicolas Janssen Mar 04 '16 at 04:47

0 Answers0