2012-04-01 4 views
0

Ich weiß nicht genau, wie es dazu kam auf diese Weise zu sein, aber hier ist die Situation:Mein Entwicklungsdatenbank- und Produktionsdatenbankschema ist irgendwie anders geworden und ich kann sie nicht synchronisieren. Wie geht man mit dieser Situation um?

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. 

Wie kann ich dieses Problem umgehen, bewegend auf? Eine Möglichkeit, die ich mir vorstellen kann, ist, eine Migration auf dem Dev-Server einmal auszuführen, nach der ich die Migrationsdatei entferne, sodass diese Migration drop_table nicht mehr zurückliegt. Aber ich bin mir nicht sicher, ob das der richtige Weg ist. Könnte mich jemand aufklären?

Antwort

0

Ja, der einfachste (und wohl richtigste) Weg ist es, Ihre invitations Tabelle in die Entwicklung fallen zu lassen. Sie müssen nicht einmal eine (temporäre) Migrationsdatei erstellen, sondern diese einfach von der Konsole oder vom Admin-Tool löschen.

+0

Vielen Dank! Hab das gerade gemacht :) – Vlad