rails add column next to
rails generate migration AddNewColumnToTableName new_column_name:data_type
rails db:migrate
Explanation:
The first command generates a new migration file in the
db/migrate
directory with a name likeYYYYMMDDHHMMSS_add_new_column_to_table_name.rb
. ReplaceAddNewColumnToTableName
with a meaningful name for your migration andnew_column_name:data_type
with the desired column name and its data type.The second command executes the pending migrations and updates the database schema.