0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

#Rails で カラム名変更の migration ファイルの例

Last updated at Posted at 2019-12-22

あーマイグレーションファイルを書くのが死ぬほど面倒だ

rails generate migration ChangeColumnNameUserFirstNameToGivenName
class ChangeColumnNameUserFirstNameToGivenName < ActiveRecord::Migration[5.2]
  def change
    # テーブル名は複数形で書く
    # 2番目に変更前のカラム名、3番目に変更後のカラム名を書く
    rename_column :users, :first_name, :given_name
  end
end

rails db:migrate

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?