Wednesday, December 3, 2008

Importing SQL Databases

I was working on merging in a branch to our master branch and did rake db:migrate like you do when people have added in some migrations. My pair and I realized that the branch was not ready for merging as there were still a lot of failing tests and so decided to leave it to the person working on that branch to fix.

So there's the pre-story. Now my database was all screwed up and so all the tests back in master were failing because things like "user_name" was changed to "user_firstname" and so on. So I did
rake db:migrate:reset
This is a pretty strong reset and deletes everything....so know, "With great power comes great responsibility"

To get my system back on track we did a sql dump of all the data that had been added and to add it back you do the following (one of many ways):
  1. Download the sql dump file
  2. Go to the folder where the file is
  3. Go into mysql
  4. show databases;
  5. use database_name; (where "database_name" is the one you want to repopulate)
  6. source filename.sql; (where "filename.sql" is the sql dump)
That's all there is to it.

No comments: