【发布时间】:2017-08-03 05:54:33
【问题描述】:
删除列“类型”后,我无法在 Heroku 应用上迁移数据库
class RemoveTypeFromMandats < ActiveRecord::Migration[5.0]
def change
remove_column :mandats, :type, :boolean
end
end
我删除了这个专栏,因为我的名字弄错了, 列不能命名为“类型”
但是现在当我尝试在 heroku 上迁移我的数据库时,我遇到了这个错误
D, [2017-03-13T08:39:10.619658 #4] DEBUG -- : (3.9ms) ALTER TABLE "mandats" DROP "type"
D, [2017-03-13T08:39:10.623526 #4] DEBUG -- : (3.5ms) ROLLBACK
D, [2017-03-13T08:39:10.627178 #4] DEBUG -- : (3.3ms) SELECT pg_advisory_unlock(157042690317842070)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedColumn: ERROR: column "type" of relation "mandats" does not exist
: ALTER TABLE "mandats" DROP "type"
【问题讨论】:
-
没有像
type这样的列存在名称,您运行了该列的 remove_column -
所以我必须删除迁移?
-
column_exists?you 可以用于该迁移
标签: ruby-on-rails ruby postgresql heroku database-migration