简体   繁体   English

我更改了列名,现在 heroku db:migrate 不起作用,因为该列不存在

[英]I changed the column name, now heroku db:migrate doesn't work because the column doesn't exist

I changed the name of my 'image_url' column in my 'visions' table to 'image'.我将“visions”表中“image_url”列的名称更改为“image”。 However, now when I try the command heroku run rake db:migrate , I get the error: PG::UndefinedColumn: ERROR: column "image_url" does not exist但是,现在当我尝试命令heroku run rake db:migrate ,出现错误: PG::UndefinedColumn: ERROR: column "image_url" does not exist

rails db:migrate works fine. rails db:migrate 工作正常。 However, heroku run rake db:migrate gives me the error.但是, heroku run rake db:migrate 给了我错误。

this is my migration file for changing the column name:这是我用于更改列名的迁移文件:

  def change
    rename_column :visions, :image_url, :image
  end
end

My schema for that table:我对该表的架构:

    t.string "description"
    t.string "image"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.bigint "user_id"
    t.index ["user_id"], name: "index_visions_on_user_id"
  end

尝试运行$ heroku run "bundle exec rake db:schema:dump && cat db/schema.rb"以获取 heroku 模式,以便您可以检查 Visions 表中有哪些列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM