rename table rails code example
Example 1: how to rename a table in ruby
class RenameOldTableToNewTable < ActiveRecord::Migration
def change
rename_table :old_table_name, :new_table_name
end
end
Example 2: rename column in db rails
rails generate migration rename_title_to_name_in_tasks
Example 3: rename column in db rails
class RenameTitleToNameInTasks < ActiveRecord::Migration[6.0]
def up
rename_column :tasks, :title, :name
end
def down
rename_column :tasks, :name, :title
end
end