Ruby on Rails Renaming a Database Column

Ruby on Rails Renaming a Database Column

To rename a database column, first you need to create a migration:

Terminal commands line:

1
rails g migration RenameColumnXinTableYtoZ

Next you need to edit the migration and add the following line:

1
rename_column :table, :old_column, :new_column

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

So far so good, That’s it!!! See ya!!! :)