Reputation: 4706
When creating a model in Rails, I forgot to add a column amount
that I want. How can I add it to the model later?
Upvotes: 13
Views: 13834
Reputation: 306
The lazy way:
rails g migration add_amount_to_items amount:integer
Upvotes: 11
Reputation: 1296
Create a new migration via the console with:
rails g migration add_amount_to_items
This should create a migration something like this:
class AddAmountToItems < ActiveRecord::Migration
def change
# add_column table_name, :column_name, :column_type
add_column :items, :amount, :integer
end
end
Upvotes: 17