Ruby on rails 列删除后rails DB heroku迁移错误
在删除列“type”后,我在heroku应用程序上迁移数据库时遇到问题 你可以试试Ruby on rails 列删除后rails DB heroku迁移错误,ruby-on-rails,ruby,postgresql,heroku,database-migration,Ruby On Rails,Ruby,Postgresql,Heroku,Database Migration,在删除列“type”后,我在heroku应用程序上迁移数据库时遇到问题 你可以试试 class RemoveTypeFromMandats
class RemoveTypeFromMandats
您可以试试
class RemoveTypeFromMandats
不存在类似类型的列名称,您运行了该列的“删除”列,因此我必须删除迁移?列是否存在
您可以在该迁移上使用没有列名称,如type
,您运行了该列的remove\u列,因此我必须删除迁移?column\u exists代码>可以在该迁移中使用
class RemoveTypeFromMandats < ActiveRecord::Migration[5.0]
def change
remove_column :mandats, :type, :boolean
end
end
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"
class RemoveTypeFromMandats < ActiveRecord::Migration[5.0]
def change
if column_exists? :mandats, :type
remove_column :mandats, :type, :boolean
end
end
end