I am a beginner at Ruby on Rails and so i apologize if this sounds like quite apparent, but I am learning crafting the database migration scripts and Let me alter the following lengthy_description to some text value rather than string:

class CreateArticles < ActiveRecord::Migration
  def self.up  
    create_table :articles do |t|
      t.column "short_description", :string
      t.column "long_description", :string
      t.timestamps
    end
  end
end

Any ideas how you could do?

class CreateArticles < ActiveRecord::Migration
  def self.up
    create_table :articles do |t|
      t.string :short_description
      t.text :long_description
      t.timestamps
    end
  end
  def self.down
    # don't forget the down method
  end
end

Also, remember the down method.

Migration types are listed here.

  • :string
  • :text
  • :integer
  • :float
  • :decimal
  • :datetime
  • :timestamp
  • :time
  • :date
  • :binary
  • :boolean
create_table :articles do |t|
  t.column 'long_description', :text
  # ...
end

Place it to :text

Here is a good ref for you personally: Here