rails 列删除后数据库 heroku 迁移错误
rails DB heroku migration error after column drop
在删除我的专栏 "type"
后,我无法在我的 heroku 应用程序上迁移我的数据库
class RemoveTypeFromMandats < ActiveRecord::Migration[5.0]
def change
remove_column :mandats, :type, :boolean
end
end
我放弃这个专栏是因为我用错了名字,
无法命名列 "type"
但是现在当我尝试在 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"
你可以试试column_exists?
class RemoveTypeFromMandats < ActiveRecord::Migration[5.0]
def change
if column_exists? :mandats, :type
remove_column :mandats, :type, :boolean
end
end
end
在删除我的专栏 "type"
后,我无法在我的 heroku 应用程序上迁移我的数据库class RemoveTypeFromMandats < ActiveRecord::Migration[5.0]
def change
remove_column :mandats, :type, :boolean
end
end
我放弃这个专栏是因为我用错了名字, 无法命名列 "type"
但是现在当我尝试在 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"
你可以试试column_exists?
class RemoveTypeFromMandats < ActiveRecord::Migration[5.0]
def change
if column_exists? :mandats, :type
remove_column :mandats, :type, :boolean
end
end
end