Dump an Existing Database Schema Into a Ruby On Rails Migration Ready Format
I have been looking around for a plugin or bit of code that can dump the schema from an existing database into the Ruby on Rails database migration format. The solution is a 'duh' moment, and probably obvious to most Rails programmers. All you have to do is change your database.yml file so that it points to the existing database you want to dump. Next run rake db:schema:dump. The schema.rb file in your db directory will now contain a dump of all the tables and indexes in your old database. Rename the schema.rb file to something else so that it doesn't get over written. Don't forget to change your database.yml file to back and now you only need to copy and paste what you need from the schema file into your migrations. This one should have been obvious, and it can save you an insane amount of time.
More from jbasdf
- A copy of ApplicationController has been removed from the module tree but is still active! And can’t dup NilClass
- Mac OSX and the Samsung ML1740 on a network
- Ajax calls using jQuery in Ruby on Rails
- Implicit multipart emails using Ruby on Rails and ActionMailer won’t work
- Shoulda Doesn’t like ‘Status’
-
Marc Mengel
-
Steve K
-
Thom Parkin
-
ariel
-
Gerald Byrket
-
Justin Ball
-
glennswest
-
Dietrich Speer
-
Justin Ball
-
Bob Campbell
-
Justin Ball
-
Bob Campbell
-
billitch
-
jbasdf
Justin Ball is a software consultant and entrepreneur with a passion for Ruby. He evolved from a C++ and .Net monkey into a python programmer and finally found Ruby. In the rare moments when he isn't writing code, talking about code or measuring his code productivity in profanity per hour, you can find him on his bike in the mountains or on the roads surrounding Cache Valley. 









