所以我犯了一个愚蠢的错误,即手动从我的项目中删除迁移文件。
它们仍然显示在 db:migrate:status
中,但我无法rollback
或destroy
它们,除非使用 MigrationID_somename 创建新的空文件,然后对这些占位符文件运行 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)
您可能只使用数据库客户端并从schema_migrations表中删除行(如果您承诺不再这样做;)。