I have two cars ... a development machine and a production machine. When I first brought the rails application to a production server, I had no problems. I just imported schema.rb by running rake db: schema: load RAILS_ENV = production. All was good.
So, then on my development machine, I made a few changes and another migration, and then copied the new application to the production machine. Then I tried updating the database by doing rake db: migrate RAILS_ENV = production. I get the following error: "The database already has an object named" schema_migrations ".
I think to myself, I'm not joking, Rake ... you created it! I ran after the rake, and it seems that the rake thinks this is the first time he has ever run. However, by analyzing the schema_migrations table on my development machine and my production machine, you can see that there is a difference in one migration, namely the one I want to migrate.
I also tried to explicitly determine the version number, but this does not work either.
Any ideas on how I can upgrade my production server?
Update:
Let me start by saying that I cannot just drop the database. This is a production server with just over 100 thousand records. What happens if a similar problem arises in the future? Am I just throwing a table every time there is a database problem? This may work this time, but it doesn't seem like a practical long-term solution to every database problem. I doubt that my problem is unique to me right now.
It looks like the schema_info table and the schema_migrations table are the same. In my setup, I only have "schema_migrations". As stated earlier, the difference between the schema_migrations table on the production server and the development machine is just one record. That is, a record containing the version number of the change I want to transfer.
From the book I read “Simply Rails 2,” it says that when you first go to the production server, instead of running rake db: migrate, you just need to run rake: db: schema: load.
If that matters, I'm using Rails version 2.1.
source share