It might be convenient to put all the lines we type inside of bash to create the whole initial project inside a script, for all the scaffold creations, rake db:migrate, and even the git commands, so that if we ever need to create the same project under Rails 4 or 5, that will be very simple.
But for a migration file that adds index to a table column, is there a way to specify that on the command line or somehow automate that on the command line? Otherwise we will need to put in the command for the migration file creation and then manually edit that file by hand — if everything can be put in a script, that can be kind of neat.
(or if the index can be specified in the scaffold line, that might be even better)
When generating your model’s migration, use
indexafter the field name for a regular index anduniqfor a unique index.Example:
You can probably do something similar when generating just a migration