IBM DB2 and Migrations

The IBM DB2 adapter supports ActiveRecord migrations. Migrations are a powerful tool that can be used with DB2, however there are a few transformations that are not implemented yet.

Available transformations:

  • create_table(name, options)
  • drop_table(name)
  • rename_table(old_name, new_name)
  • add_index(table_name, column_name, index_type)
  • remove_index(table_name, column_name)
  • add_column(table_name, column_name, type, options)
  • remove_column(table_name, column_name)

Not implemented yet:

  • rename_column(table_name, column_name, new_column_name)
  • change_column(table_name, column_name, type, options)

And here is an example of a migration file that works with DB2:


class CreateCustomers < ActiveRecord::Migration
  def self.up
    create_table :customers do |t|
      t.column "name", :string, :limit => 100
      t.column “balance”, :integer, :default => 500
      t.column “address_street”, :string, :limit => 100
      t.column “address_city”, :string, :limit => 100
      t.column “address_country”, :string, :limit => 100
      t.column “gps_location”, :string, :limit => 100
    end
  end

  def self.down
    drop_table :customers
  end
end
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Posted by Admin | October 15 2007 11:20 pm

Trackback URI | Comments RSS

Leave a Reply