To rename a database column, first we need to create a migration.

Terminal Commands:

rails g migration RenameColumnXinTableYtoZ

Next, we need to edit the migration and add the following line.

db/migrate/xxxxxxxxxxxxxx_rename_column_x_in_table_y_to_z.rb:

rename_column :table, :old_column, :new_column

Finally, run a rake db:migrate and you are all set.