迁移错误&回滚尝试

时间:2015-04-13 04:19:45

标签: ruby-on-rails sqlite migration rollback

目前正在制作一个reddit类型的网站,并且发现(无论出于什么原因)我工作其他“活动部件”后不再存在创建注释的迁移。我继续生成一个新的评论迁移,并且遇到了一个很好的墙壁“StandardError:发生了错误,这个和所有后来的迁移都被取消了:[...]”我研究了回滚/删除迁移来解决我的问题,但似乎无法到达任何地方。下面是我努力修复我的应用程序的结果,然后我太害怕完全破坏它。

Kristoffers-MBP:bloccit Juice$ rake db:migrate:status

database: /Users/Juice/code/bloccit/db/development.sqlite3

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20150315080918  Create advertisements
   up     20150321042053  Devise create users
   up     20150323040831  Add role to users
   up     20150328164720  Create topics
   up     20150328170242  Add topic to posts
   up     20150405212530  Add avatar to users
   up     20150406044601  ********** NO FILE **********
  down    20150412173406  Create comments

Kristoffers-MBP:bloccit Juice$ rake db:rollback
Kristoffers-MBP:bloccit Juice$ rake db:migrate:status

database: /Users/Juice/code/bloccit/db/development.sqlite3

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20150315080918  Create advertisements
   up     20150321042053  Devise create users
   up     20150323040831  Add role to users
   up     20150328164720  Create topics
   up     20150328170242  Add topic to posts
   up     20150405212530  Add avatar to users
   up     20150406044601  ********** NO FILE **********
  down    20150412173406  Create comments

Kristoffers-MBP:bloccit Juice$ rake db:rollback
Kristoffers-MBP:bloccit Juice$ rake db:migrate:status

database: /Users/Juice/code/bloccit/db/development.sqlite3

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20150315080918  Create advertisements
   up     20150321042053  Devise create users
   up     20150323040831  Add role to users
   up     20150328164720  Create topics
   up     20150328170242  Add topic to posts
   up     20150405212530  Add avatar to users
   up     20150406044601  ********** NO FILE **********
  down    20150412173406  Create comments

Kristoffers-MBP:bloccit Juice$ rake db:rollback
Kristoffers-MBP:bloccit Juice$ rake db:migrate:status

database: /Users/Juice/code/bloccit/db/development.sqlite3

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20150315080918  Create advertisements
   up     20150321042053  Devise create users
   up     20150323040831  Add role to users
   up     20150328164720  Create topics
   up     20150328170242  Add topic to posts
   up     20150405212530  Add avatar to users
   up     20150406044601  ********** NO FILE **********
  down    20150412173406  Create comments

Kristoffers-MBP:bloccit Juice$ rake db:migrate:down VERSION=20150412173406
Kristoffers-MBP:bloccit Juice$ rake db:migrate:status

database: /Users/Juice/code/bloccit/db/development.sqlite3

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20150315080918  Create advertisements
   up     20150321042053  Devise create users
   up     20150323040831  Add role to users
   up     20150328164720  Create topics
   up     20150328170242  Add topic to posts
   up     20150405212530  Add avatar to users
   up     20150406044601  ********** NO FILE **********
  down    20150412173406  Create comments

1 个答案:

答案 0 :(得分:1)

尝试: rake db:drop

rake db:create

rake db:migrate

注意:数据库中所有已保存的数据都将丢失。