Add a new column to a table
suggest changeTo 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 has the form AddXXXToTABLE_NAME, followed by a list of columns and data types, the generated migration contains the matching add_column statements.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents