Rails& Heroku - 迁移数据库错误

时间:2018-01-25 03:41:42

标签: ruby-on-rails heroku

我第一次尝试将我的Rails项目部署到Heroku,并且我在数据库迁移中遇到错误。这似乎是从我的数据库中删除一列的结果,但我从那里丢失了,并且不知道下一步要采取什么步骤。所有迁移都是最新的,并且在开发模式下工作正常。以下是我收到的错误消息:

D, [2018-01-25T03:33:27.361851 #4] DEBUG -- :    (0.8ms)  SELECT pg_try_advisory_lock(5611133814980990205)
D, [2018-01-25T03:33:27.377916 #4] DEBUG -- :    (1.4ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
I, [2018-01-25T03:33:27.379169 #4]  INFO -- : Migrating to RemoveCoinFromQuestions (20180121170335)
D, [2018-01-25T03:33:27.384613 #4] DEBUG -- :    (3.6ms)  BEGIN
== 20180121170335 RemoveCoinFromQuestions: migrating ==========================
-- remove_column(:questions, :coin, :string)
D, [2018-01-25T03:33:27.387289 #4] DEBUG -- :    (2.3ms)  ALTER TABLE "questions" DROP "coin"
D, [2018-01-25T03:33:27.388188 #4] DEBUG -- :    (0.7ms)  ROLLBACK
D, [2018-01-25T03:33:27.389388 #4] DEBUG -- :    (0.8ms)  SELECT pg_advisory_unlock(5611133814980990205)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedColumn: ERROR:  column "coin" of relation "questions" does not exist
: ALTER TABLE "questions" DROP "coin"
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `async_exec'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `block (2 levels) in execute'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:72:in `block in execute'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block (2 levels) in log'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:611:in `block in log'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:603:in `log'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:71:in `execute'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:576:in `remove_column'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:849:in `block in method_missing'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:818:in `block in say_with_time'

架构:

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

  create_table "coins", force: :cascade do |t|
    t.string "link_name"
    t.string "currency_name"
    t.string "currency_abbrev"
    t.float "volume_usd"
    t.float "volume_btc"
    t.string "picture"
    t.string "website1"
    t.string "website2"
    t.string "website3"
    t.string "website4"
    t.string "website5"
    t.string "website6"
    t.string "website7"
    t.string "website8"
    t.text "question1"
    t.text "question2"
    t.text "question3"
    t.text "question4"
    t.text "question5"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.string "permalink"
    t.string "genre"
    t.integer "moderator_id"
  end

  create_table "events", force: :cascade do |t|
    t.text "content"
    t.integer "coin_id"
    t.integer "user_id"
    t.boolean "accepted", default: false
    t.integer "upvotes", default: 0
    t.integer "downvotes", default: 0
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.string "link"
    t.string "picture"
    t.date "date"
    t.time "time"
  end

  create_table "questions", force: :cascade do |t|
    t.integer "ques_num"
    t.text "content"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.integer "user_id"
    t.integer "coin_id"
    t.boolean "accepted"
    t.index ["coin_id"], name: "index_questions_on_coin_id"
    t.index ["user_id"], name: "index_questions_on_user_id"
  end

  create_table "users", force: :cascade 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", null: false
    t.datetime "updated_at", null: false
    t.string "username"
    t.string "fname"
    t.string "lname"
    t.string "wallet"
    t.boolean "admin", default: false
    t.boolean "moderator", default: false
    t.index ["email"], name: "index_users_on_email", unique: true
    t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
    t.index ["username"], name: "index_users_on_username", unique: true
  end

  create_table "views", force: :cascade 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", null: false
    t.datetime "updated_at", null: false
    t.index ["email"], name: "index_views_on_email", unique: true
    t.index ["reset_password_token"], name: "index_views_on_reset_password_token", unique: true
  end

end

如果有人能指出我在这方面的正确方向,我们将不胜感激。

0 个答案:

没有答案