I don’t exactly know how it came to be this way, but here’s the situation:
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.
How can I get around this problem, moving on? Right now, one way I can think of is running a migration on the dev server once, after which I remove the migration file, so there would be no history of this drop_table migration left. But i’m not sure if this is the right way. Could anyone enlighten me?
Yes, the easiest (and, arguably, most correct) way is to drop your
invitationstable in the development. You don’t even have to create a (temporary) migration file, just drop it from the console or admin tool.