The world of .NET and Web Programming

Ruby, Ruby on Rails Killer Feature: DB Migrations

I think I made a mistake at the begining of last year when I chose Python as my language of 2005. It really should have been Ruby. I have been playing with Ruby the last few days and I am falling in love. Its powerful but simple. Its way more understandable than Python or Perl and very little has to be written to do some amazingly powerful stuff. I am adding a Ruby Category on this blog. I am not too interested in building web applications with Ruby on Rails but the killer feature of Rails has to be the Database Migrations which solve the hard problem of rolling out changes to your database. As Steve shows, its as simple as this:
class AddUserTable < ActiveRecord::Migration
    def self.up
      create_table :users do |table|
        table.column :name, :string
        table.column :login,  :string
        table.column :password, :string, :limit => 32
        table.column :email, :string
      end
    end

    def self.down
      drop_table :users
    end
  end
Migrations not only support migrating a database from a previous version to the current version but it also supports rolling back database changes. 
This absoutely rocks! Its an elegant solution to a tedious problem that takes forever to automate correctly. Here are some resources:

 

» Trackbacks & Pingbacks

    No trackbacks yet.
Trackback link for this post:
http://samgentile.com/Web/trackback.ashx?id=76

» Comments

    There are no comments. Kick things off by filling out the form below.

» Leave a Comment