Add a new column to a table

suggest change

To add a new column name to the users table, run the command:

rails generate migration AddNameToUsers name

This generates the following migration:

class AddNameToUsers < ActiveRecord::Migration[5.0]
  def change
    add_column :users, :name, :string
  end
end

When the migration name is of the form AddXXXToTABLE_NAME followed by list of columns with data types, the generated migration will contain the appropriate add_column statements.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


ActiveRecord migrations:
* Add a new column to a table

Table Of Contents
3 Views
4 ActiveRecord migrations
19 Caching
23 Rails 5
25 Mongoid
26 Gems
55 CSV