我不知道这是怎么回事,但情况如下:
1. I was experimenting with the combination of "git reset --hard HEAD" and "git clean -f"
2. For some reason when I did this, it only removed the migration file, but didn't really revert my sqlite database to the previous version.
3. I committed and pushed some more without realizing this
4. At the point I found this out, my development server had the following code:
create_table "invitations", :force => true do |t|
t.string "recipient_email"
t.datetime "created_at"
t.datetime "updated_at"
end
but my production server doesn't.
5. I tried to generate a new migration that drops invitations table. It works on the dev server since there is an existing invitations table. However when I push it and try to rake db:migrate on Heroku, it spits out error (obviously) because there is no such table over there to drop.
如何解决这个问题,继续前进?现在,我能想到的一种方法是在dev服务器上运行一次迁移,之后我删除了迁移文件,因此没有剩下这个drop_table迁移的历史记录。但我不确定这是否正确。谁能开导我?
答案 0 :(得分:0)
是的,最简单的(也可以说是最正确的)方法是将invitations
表放在开发中。您甚至不必创建(临时)迁移文件,只需从控制台或管理工具中删除它。