Slide 27
Slide 27 text
残り30%を埋めたい
● どのテーブルのどのカラムにコメントがないのか?プログラムで調べる。
● プログラムでコメント追加用のコードを生成させた。
● あとは無心にtoのところにコメントを書いていくのみ。
# table_with_columnsは、テーブル名をキーとする Hashオブジェクト
table_with_columns.each do |table, columns|
columns.each do |column|
puts "change_column_comment(:#{table}, :#{column.name}, from: nil, to: '')"
end
end
# => 出力は以下のように …。これをマイグレーションファイルにコピー &ペーストする
change_column_comment(:posts, :id, from: nil, to: '')
change_column_comment(:posts, :title, from: nil, to: '')
change_column_comment(:posts, :content, from: nil, to: '')
change_column_comment(:tags, :id, from: nil, to: '')
change_column_comment(:tags, :name, from: nil, to: '')