所以我犯了从项目中手动删除迁移文件的愚蠢错误。
它们仍会显示在db:migrate:status
中,但如果没有使用MigrationID_somename创建新的空文件,然后在这些占位符上运行destroy,我就无法rollback
或destroy
它们文件。
有没有更好的方法可以忘记丢失的迁移文件?
me$ rake db:migrate:status
database: [...]/db/development.sqlite3
Status Migration ID Migration Name
--------------------------------------------------
up 20141203044050 ********** NO FILE **********
up 20141203044501 ********** NO FILE **********
me$ rake db:migrate:down VERSION=20141203044501
rake aborted!
ActiveRecord::UnknownMigrationVersionError:
No migration with version number 20141203044501
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:932:in `run'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:818:in `run'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:79:in `block (3 levels) in <top (required)>'
Tasks: TOP => db:migrate:down
(See full trace by running task with --trace)
答案 0 :(得分:4)
您可能只是使用数据库客户端并从schema_migrations表中删除行(如果您保证永远不会再次执行;)。