01 April 2007

Converting legacy php database to Rails

I've been working on converting an old php application to Ruby on Rails. Several months ago during the development process, I wrote some scripts to take the data from the old database and insert it into the new one, performing any necessary adjustments to the data that was needed. I ran into a problem when I needed to do it again recently in preparation for the move into production because I couldn't remember how I did it the first time. So, here it is:

I used the script outline talked about here: Rewriting a (large) PHP application in Rails, part 1

The database_configuration["old_production"] in the example is pointing to a database connection named "old_production" in the database.yml file.

I saved the script in /lib under my rails app root directory, and to run it use:

../script/runner 'load "my_conversions_script.rb"'



No comments: