The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Database Management in Rails

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Stewart

Posts: 72
Nickname: estewart
Registered: Dec, 2003

Eric Stewart is software developer from Austin, Texas.
Database Management in Rails Posted: Nov 17, 2005 5:30 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eric Stewart.
Original Post: Database Management in Rails
Feed Title: Ponderings On Ruby
Feed URL: http://blog.eric-stewart.com/category/programming-ruby.rss
Feed Description: This is the Ruby related section of Eric Stewart's weblog. These entries will be the commentary of a long time Java/C++ programmer that started exploring Ruby in 2003.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eric Stewart
Latest Posts From Ponderings On Ruby

Advertisement

My current Rails project is a port of a previously deployed system. That means it already has lot’s of great data that the new version will want. But the client had no real attachment to the original DB schema and in fact prefers that it be migrated to a different DBMS for deployment on a different type of system.

After weighing a few different options, we found a great way to do this. SQL Server (the original DBMS) has a handy export facility to spit out data in CSV format. I found a great little Ruby CSV Library that will do all the reading we need (and would do lot’s of writing too if we needed it). Voila! A script to read the CSV. Now to write those records to the new DB.

ActiveRecord to the rescue! Fortunately ActiveRecord, a base component of Rails but quite useful on it’s own, is well suited to the task. Thanks to a little tip from the Rails Wiki, it’s extremely easy to add writing the CSV data we read into our new rails project database. And, as it turns out, very easy to reprocess it all the time as we find new uses for the data that was exported.

I’m sure there’s a fancier way to do all this, but what we found works quite well. Now migrating a table takes about 5 minutes (if we include designing the schema in the new DB and generating the model classes that is)!

Read: Database Management in Rails

Topic: Dammit Firefox Previous Topic   Next Topic Topic: Digging for Clues

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use