【发布时间】:2018-09-23 14:49:10
【问题描述】:
我已经销毁了一个脚手架“Location”及其表,但我忘记在销毁“Location”表之前回滚/删除迁移的列“slug 及其索引”。如何删除 slug 和索引的迁移。
迁移的 slug 列
class AddSlugToLocations < ActiveRecord::Migration[5.1]
def change
add_column :locations, :slug, :string
add_index :locations, :slug
end
end
非常感谢您的帮助,因为这个问题,heroku 不会部署
我试过ActiveRecord::SchemaMigration.where(version=20180412191332).delete_all,但没有成功
也尝试了rake db:migrate:down VERSION=20180412191332,但出现错误:在提供选项的位置上找不到索引。
【问题讨论】:
-
您是如何删除位置信息的?与另一次迁移?
-
@AnaMaríaMartínezGómez,我用过
rake db:migrate:down VERSION=<version for location>,用过rail destroy scaffold Location -
当表已经被删除时,索引也被删除。还是我错过了什么?
-
为什么不直接删除
AddSlugToLocations迁移? -
据我了解整个
locations表在生产中不存在,因此索引也不存在。当您删除只更改(不存在的)表的迁移时,它如何破坏应用程序?
标签: ruby-on-rails ruby postgresql ruby-on-rails-4 rubygems