Monday, February 12, 2007

Rails - DB2 - Tablespace

I realized that silly title may not result in 'google' search. So I decide to put a boring and mundane title in hopes of getting more hits.

So today's topic is DB2 and Rails.

Here is a good article on from IBM DeveloperWorks - An introduction to Ruby on Rails for DB2 developers.

The article shows how to 'setup' the tables via scaffold. However, if you are like me, DBA hates to use 'default' tablespace - USERSPACE1. I do understand why they hate it - it is like saying 'put everything under '/' partition.

However, the example does not show you how to do it.

Don't worry, my friends. The forks behind Rails already knew that we may want to pass in extra options.

So if you want to 'table' in 'TABLESPACE1' and 'index' in 'INDEXSPACE1'



class CreateProjects :options => 'in TABLESPACE1 index in INDEXSPACE1') do |t|
t.column "name", :string, :null => false
t.column "description", :text, :null => false
t.column "homepage", :string
t.column "license", :string
t.column "opensource", :boolean, :null => false
t.column "notes", :text
t.column "updated_on", :timestamp
t.column "created_on", :timestamp
end
end

def self.down
drop_table :projects
end
end



Sorry - I had to take off the formatting - if I use "<\pre>" html directive, the line was getting chopped off in Firefox.