rails add column next to

rails generate migration AddNewColumnToTableName new_column_name:data_type
rails db:migrate

Explanation:

  1. The first command generates a new migration file in the db/migrate directory with a name like YYYYMMDDHHMMSS_add_new_column_to_table_name.rb. Replace AddNewColumnToTableName with a meaningful name for your migration and new_column_name:data_type with the desired column name and its data type.

  2. The second command executes the pending migrations and updates the database schema.