[RUBY] Migration file to add comment to Rails table

Migration file

class AddCommmentsToStaffEmail < ActiveRecord::Migration[6.0]
  def change
    change_column_comment(:staff_emails, :employee_id, 'Trader ID') 
  end
end

change_column_comment Enter the table name, column name, and comment content in change_column_comment.

change_column_comment(:table_name, :column_name, 'contents') 

environment

Execution procedure

Creation of migration file

command

cmd.


$bundel exec rails g migration AddCommentsToTable

Perform migration

command

cmd.


$bundel exec rake db:migrate

Remarks

--Reference link

http://hotoolong.hatenablog.com/entry/2018/06/20/083106

Recommended Posts

Migration file to add comment to Rails table
[Rails] Add page nation to table [For beginners]
Rails "How to delete NO FILE migration files"
[rails] Deleted NOFILE migration file
[Rails] Add column to devise
[Rails] Delete the migration file
[Rails] Steps to fix problems caused by deleting my sql table and migration file
Add Extended Attributes to the file
How to add columns to a table
[Rails] How to add new pages
[Rails] Add strong parameters to devise
Rails migration
[Xcode] How to add a README.md file
How to delete the wrong migration file
How to delete the migration file NO FILE
Upload Rails app image file to S3
How to add jar file in ScalaIDE
[Rails] [Memo] When to add = to <%%> and when not
[Rails] I learned about migration files! (Adding a column to the table)
[Rails] How to create a table, add a column, and change the column type
Add binding.pry (rails)
How to add / remove Ruby on Rails columns
Add a tag function to Rails. Use acts-as-taggable-on
How to conditionally add html.erb class in Rails
Introduction to migration
Add jar file obtained from Maven to IntelliJ
[Spring Batch] Output table data to CSV file
[Rails] How to change the column name of the table
What to do when rails creates a 〇〇 2.rb file
[Rails 6] Add images to seed files (using Active Storage)
Completely delete the migration file that you failed to delete
I want to add a delete function to the comment function
[Rails] About migration files
Add files to jar files
[Rails] Migration command summary
How to write Rails
Introducing CircleCI to Rails
Introducing Bootstrap to Rails 5
Various rails migration operations
Introducing Bootstrap to Rails !!
Introduce Vue.js to Rails
How to uninstall Rails
Understand migration in rails
[Rails] Processing after adding a column to the devise table
Add an icon to the header link using Rails fontawesome
How to write a migration from Rails datetime type to date type
What to check when rails db: migration does not pass
[Rails5] japanMap link How to write parameters in js.erb file
[Rails] How to display error messages for comment function (for beginners)