How to rename a column in Rails 5

Want to run a migration to rename a column in Rails 5? First, run:

rails g migration ChangeColumnName

Next, open the resulting migration and add the rename_column line below. Make sure to change table_name, old_column, and new_column to your own values.

table_name should be plural.

class ChangeColumnName < ActiveRecord::Migration[5.2]
def change
rename_column :table_name, :old_column, :new_column

Now, run rails db:migrate.