Migrations ain't just cool...they're sexy!

by Michael McClenaghan 2007-03-30

Migrations are one of those things in Rails that blows me away. I haven't actually tried to use a single migration with different databases to see how good the abstraction is but I love the idea.

As if merely having migrations wasn't good enough, somebody has decided to make them sexy on top of it.

My current sideline project has a ton of tables with a lot of relationships. I'm starting to get tired of adding all of the foreign key references in each migration. While the new sexy_migrations plugin doesn't get rid of those FK's, it definitely makes them a bit nicer to look at. Check out this example:

[source:ruby] class UpdateYourFamily < ActiveRecord::Migration create_table :updates do

foreign_key :user
foreign_key :group

text   :body
string :type

timestamps!

end

def self.down

drop_table :updates

end end [/source]

Is that nice or what?

blog comments powered by Disqus