IBM DB2 and Migrations
The IBM DB2 adapter supports ActiveRecord migrations, both the old “t.column” style and the newer “sexy migrations”. This means that DB2 will work fine with the migration files created by the migration and scaffold generators, as well as with handmade ones.
Migrations can be a powerful tool when it comes to handling the schema evolution, something that DB2 developers can take full advantage of. Migration files targeted at DB2 can, in fact, even use XML columns so that you can work with pureXML from within Rails (e.g. t.xml :order).
The only current caveat is that the less common rename_column transformation is not available yet. The API development team is working on this and it should be be available in the next version of the gem.
Posted by Admin | October 15 2007 11:20 pm
on Rails
Brandon on 09 Nov 2008 at 3:10 pm #
Is this still the case with the 1.0 release?
Antonio Cangiano on 19 Nov 2008 at 11:13 am #
Hi Brandon, change_column has been implemented so the only method that’s missing is rename_column, which is not trivial to implement for the current version of DB2. That said, I’ve asked the API team to give this priority, so that DB2 can have full support for Rails migrations, and they are working on it.
Long on 26 Mar 2009 at 3:52 pm #
I spent a good part of the day testing DB2 viability with Rails and found a number limitations:
1. rake globalize:setup fails with SQL0104N An unexpected token “,” was found following “2) DEFAULT NULL NULL”
Fixed this in ibm_db_adapter.rb with a modified version from super class:
def add_column_options!(sql, options) #:nodoc:
sql << ” DEFAULT #{quote(options[:default], options[:column])}” if options_include_default?(options)
# must explcitly check for :null to allow change_column to work on migrations
if options.has_key? :null
if options[:null] == false
sql << ” NOT NULL”
end
end
end
2. insert statements with quoted numeric values abort with error - cannot convert type. For example ID=’1234′. DB2 limitation, though can be hacked.
3. migration script to change column type from INT to VARCHAR aborts with error. DB2 limitation.
That is as far as I got … don’t feel like beating myself up anymore