Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

How can I rename a database column in a Ruby on Rails migration?

rails generate migration rename_title_to_name_in_tasks

class RenameTitleToNameInTasks < ActiveRecord::Migration[6.0]
  def change
    rename_column :tasks, :title, :name
  end
end
Comment

rails migration rename column

rename_column :table, :old_column, :new_column
Comment

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
Comment

rename column in db rails

rails generate migration rename_title_to_name_in_tasks
Comment

PREVIOUS NEXT
Code Example
Ruby :: in query postgres jsonb rails 
Ruby :: rails migration polymorphic references 
Ruby :: rails link_to class 
Ruby :: ruby min 2 numbers 
Ruby :: rails validators 
Ruby :: rails on_delete cascade not working 
Ruby :: ruby map with index 
Ruby :: List and delete migration from rails console 
Ruby :: how to force exit server in rails 
Ruby :: length validation rails 
Ruby :: edit file terminal mac 
Ruby :: rails get asset path from console 
Ruby :: smallest base64 image string 
Ruby :: convert to ascii ruby 
Ruby :: uper case in ruby 
Ruby :: rails logger info 
Ruby :: ruby create engine using rspec and dummy 
Ruby :: rails store array in database 
Ruby :: ruby version from script 
Ruby :: ruby conditionals 
Ruby :: rails retrieve database.yml 
Ruby :: ruby check if path is a directory 
Ruby :: ruby method tap 
Ruby :: rails has_many through source 2 
Ruby :: activerecord exclude 
Ruby :: pick element from array that is part of params hash 
Ruby :: best ruby cheat sheet 
Ruby :: rails class reminders belongs_to creator 
Ruby :: rails rails admin secure page 
Ruby :: rails 7 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =