1

update: I did $heroku run rake db:schema:load and I'm not seeing the error in the trace anymore, but I'm still unable to get the application running

I'm uploading my local app to Heroku. After setting up pg within my gemfile for production, I'm facing several issues. My log is returning a PG::DuplicateTable: ERROR: relation "comments" already exists, so I dropped the table by doing rails db and deleting the table named 'comments', as I was following the advice from someone here in Stackoverflow. The thing is that after git push heroku master and run rake db:migrate, I'm still experiencing the same error message.

full trace

            StandardError: An error has occurred, this and all later migrations canceled:

            PG::DuplicateTable: ERROR:  relation "comments" already exists
            : CREATE TABLE "comments" ("id" serial primary key, "user_id" integer, "holder_id" integer, "commentable_id" integer, "commentable_type" character varying(255), "commentable_url" character varying(255), "commentable_title" character varying(255), "commentable_state" character varying(255), "anchor" character varying(255), "title" character varying(255), "contacts" character varying(255), "raw_content" text, "content" text, "view_token" character varying(255), "state" character varying(255) DEFAULT 'draft', "ip" character varying(255) DEFAULT 'undefined', "referer" character varying(255) DEFAULT 'undefined', "user_agent" character varying(255) DEFAULT 'undefined', "tolerance_time" integer, "spam" boolean DEFAULT 'f', "parent_id" integer, "lft" integer, "rgt" integer, "depth" integer DEFAULT 0, "created_at" timestamp, "updated_at" timestamp) /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `async_exec'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
            /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:205:in `create_table'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:649:in `block in method_missing'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:621:in `block in say_with_time'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:621:in `say_with_time'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:641:in `method_missing'
            /app/db/migrate/20140619200026_the_comments_create_comments.the_comments_engine.rb:4:in `change'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:595:in `exec_migration'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:579:in `block (2 levels) in migrate'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:578:in `block in migrate'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:577:in `migrate'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:752:in `migrate'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:992:in `block in execute_migration_in_transaction'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:1038:in `block in ddl_transaction'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `block in transaction'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:219:in `within_new_transaction'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/transactions.rb:208:in `transaction'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:1038:in `ddl_transaction'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:991:in `execute_migration_in_transaction'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:953:in `block in migrate'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:949:in `each'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:949:in `migrate'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:807:in `up'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:785:in `migrate'
            /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/railties/databases.rake:34:in `block (2 leve

schema.rb

    # encoding: UTF-8
    # This file is auto-generated from the current state of the database. Instead
    # of editing this file, please use the migrations feature of Active Record to
    # incrementally modify your database, and then regenerate this schema definition.
    #
    # Note that this schema.rb definition is the authoritative source for your
    # database schema. If you need to create the application database on another
    # system, you should be using db:schema:load, not running all the migrations
    # from scratch. The latter is a flawed and unsustainable approach (the more migrations
    # you'll amass, the slower it'll run and the greater likelihood for issues).
    #
    # It's strongly recommended that you check this file into your version control system.

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

      create_table "hacks", force: true do |t|
        t.text     "description"
        t.string   "image"
        t.string   "url"
        t.datetime "created_at"
        t.datetime "updated_at"
        t.string   "picture"
        t.string   "image_file_name"
        t.string   "image_content_type"
        t.integer  "image_file_size"
        t.datetime "image_updated_at"
        t.integer  "draft_comments_count",     default: 0
        t.integer  "published_comments_count", default: 0
        t.integer  "deleted_comments_count",   default: 0
        t.integer  "user_id"
      end

      add_index "hacks", ["user_id"], name: "index_hacks_on_user_id"

      create_table "identities", force: true do |t|
        t.integer  "user_id"
        t.string   "provider"
        t.string   "uid"
        t.datetime "created_at"
        t.datetime "updated_at"
      end

      add_index "identities", ["user_id"], name: "index_identities_on_user_id"

      create_table "taggings", force: true do |t|
        t.integer  "tag_id"
        t.integer  "taggable_id"
        t.string   "taggable_type"
        t.integer  "tagger_id"
        t.string   "tagger_type"
        t.string   "context",       limit: 128
        t.datetime "created_at"
      end

      add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true

      create_table "tags", force: true do |t|
        t.string  "name"
        t.integer "taggings_count", default: 0
      end

      add_index "tags", ["name"], name: "index_tags_on_name", unique: true

      create_table "users", force: true do |t|
        t.string   "email",                       default: "", null: false
        t.string   "encrypted_password",          default: "", null: false
        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.datetime "created_at"
        t.datetime "updated_at"
        t.string   "name"
        t.string   "confirmation_token"
        t.datetime "confirmed_at"
        t.datetime "confirmation_sent_at"
        t.integer  "my_draft_comments_count",     default: 0
        t.integer  "my_published_comments_count", default: 0
        t.integer  "my_comments_count",           default: 0
        t.integer  "draft_comcoms_count",         default: 0
        t.integer  "published_comcoms_count",     default: 0
        t.integer  "deleted_comcoms_count",       default: 0
        t.integer  "spam_comcoms_count",          default: 0
      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

      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

the local app is also returning the issue that is unable to find the 'comments' table.

malditojavi
  • 1,074
  • 2
  • 14
  • 28
  • 1
    THIS WILL DESTROY YOUR ENTIRE DATABASE AND ALL YOUR DATA - Just a heads up. You can try doing to `heroku pg:reset DATABASE_URL` and the run `heroku run rake db:migrate` – Matthew Leonard Jun 29 '14 at 22:26
  • If you've deleted the table and still get that error then maybe there is a conflicting migration. Do you have another migration that is also creating the comments table? – Lukas Eklund Jun 30 '14 at 19:34
  • After the update, it got stuck on the deployment to heroku, and it was related with Carrierwave gem which was not present in my gemfile - I was using Paperclip. – malditojavi Jul 01 '14 at 18:10
  • I used [this](https://stackoverflow.com/a/27558631) solution and it worked for me – stevec Sep 26 '20 at 07:13

0 Answers0