简体   繁体   中英

schema.rb got mysteriously changed into another file

Using rails 3.2.8 ruby 1.9.3 p362.

There is something seriously amiss with my rails app. After so many db issues with an app, I STARTED FROM SCRATCH - read: rails new < new app name>

And started adding scaffolds and models. All in the past hour or so.

Then I tried to migrate a model called Product and I got the "Mysql2::Error: Table 'products' already exists" message when I ran rake db:migrate

Lo-and-behold my schema.rb file transformed itself into the mess of a file I had on my old app (on a different folder).

How can this happen? And how can I fix it?

Also, how often should I be pushing to git? I pushed once before building 2 new models and I already have a mess in my hands.

Help, please!

Did you clean up the old database for migrations from your older app / create a new database for the new app? Looks like it is the older database which is causing the issues.

You can go to your mysql prompt, and do a drop database database_name; and recreate an empty database using create database database_name .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM