My name is Heath Anderson.
This is my website.

Ruby on Rails Plugin: data_migration

data_migration allows you to separate data you need to load from your normal database migrations in a minimal way. While developing the new version of our flagship site, Knetwit, we decided we needed to separate our data migrations (initial settings and the like) from our structural migrations. We decided the easiest way to do this was to modify the existing Rails migration to allow for a new data migration. So we did.

Install Plugin

script/plugin install git://

Generate Migration

script/generate data_migration BlockedDomains

exists  db/data
create  db/data/20090915161242_settings.rb[/sourcecode]


class BlockedDomains < ActiveRecord::Migration
def self.up

Add your data:

def self.up
BlockedEmailDomain.create(:domain => "")
BlockedEmailDomain.create(:domain => "")
BlockedEmailDomain.create(:domain => "")

Run Migration

rake db:data:migrate

==  BlockedDomains: migrating ===========================================================
==  BlockedDomains: migrated (0.0020s) ==================================================

db:data:migrate adds the data migration version number to the 'schema_migrations' table so it will not be ran again.

Code at Github: