Ruby on Rails - rails generate migration in ruby on rails- ruby on rails tutorial - rails guides - rails tutorial - ruby rails
Rails Generate Migration
- we can generate a rails migration file from the terminal using the following command:
- For a list of all the options supported by the command, we could run the command without any arguments as in rails generate migration.
- For example, if we want to add first_name and last_name fields to users table, you can do:
- Rails will create the following migration file:
- Now, apply the pending migrations to the database by running the following in the terminal: