Ruby on rails 我的开发数据库和生产数据库模式在某种程度上有所不同,我无法同步它们。如何处理这种情况?
我不知道怎么会这样,但情况如下:Ruby on rails 我的开发数据库和生产数据库模式在某种程度上有所不同,我无法同步它们。如何处理这种情况?,ruby-on-rails,activerecord,deployment,rails-migrations,Ruby On Rails,Activerecord,Deployment,Rails Migrations,我不知道怎么会这样,但情况如下: 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
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_表迁移的历史记录了。但我不确定这是不是正确的方法。有谁能给我点化一下吗?是的,最简单、也可以说是最正确的方法是在开发中删除邀请表。您甚至不必创建临时迁移文件,只需将其从控制台或管理工具中删除即可