varchar Migration question for Ruby on Rails

Viewed 44958

I have created a new table including a column "note". The default is varchar(255) I believe but I wish to have this column be a text area vs. a field and to allow more data. I imagine that I would make this change in ActiveRecord::Migration file but I am curious as to the format. Do I simply change the varchar(255) to varchar(1000) for example? (if so what is the format?

def self.up
    create_table :notes do |t|
      t.string :note :varchar(1000)
    end

Is that the right format? Furthermore, how do I get the entry field to be multiple rows. Sorry if this is easy stuff but I am new to programming and RoR. Thanks.

4 Answers

Since I had a lot of data already stored I used

self.up
  change_column :notes, :note, :text, :limit => nil
end

If I left off the :limit => nil option then the column type would change from varchar to text, but it still had a max length of 255 characters.

Related