rename column in db rails
Renaming a Column in Ruby on Rails
rails generate migration RenameOldColumnToNewColumn
class RenameOldColumnToNewColumn < ActiveRecord::Migration[6.0]
def change
rename_column :table_name, :old_column, :new_column
end
end
Replace table_name
, old_column
, and new_column
with the actual table name, old column name, and new column name. After running the migration, the column will be renamed in the database.