Rails generate Migration

Ivan Kutsarov picture Ivan Kutsarov · Mar 1, 2013 · Viewed 87.7k times · Source

I currently have migration called Products, and I simply want to add few more strings to this migration such as description and product type. What is the best way to do this?

class CreateProducts < ActiveRecord::Migration
  def change
    create_table :products do |t|
      t.string  :name
      t.decimal :price
      t.text    :description
      t.timestamps
    end
   end
 end

Answer

dompuAmanat Fadilla picture dompuAmanat Fadilla · Nov 15, 2013

Just run

rails g migration add_description_to_products description:string
rails g migration add_product_type_to_products product_type:string

and then run

rake db:migrate