Monday, December 21, 2009

change_column at rails

I want to change the column length of "name" column to 200 chars at FOLDER table because I got too short column SQL error.


You need to create a ChangeLengthOfNameColumnOfFolder with the following:

rake db:migrate change_length_of_name_column_of_folder


Then, update the up and down functions as follows:

class ChangeLengthOfNameColumnOfFolder < ActiveRecord::Migration
def self.up
add_column :folder, :name_sixty, :string, :limit => 200, :null => false
NaicsCategory.reset_column_information
remove_column :folder, :name
rename_column :folder, :name_sixty, :name
change_column :folder, :name, :string, :limit => 200, :null => false
end

def self.down
drop_table :folder
end
end

Then,
rake db:migrate

Introduction to Cloud Computing

  • Jongwook Woo, California State University, Los Angeles,
    Introduction to Cloud Computing
    , the 10th KOCSEA 2009 Symposium, UNLV,
    Dec 18-19, 2009