4
5

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 5 years have passed since last update.

Rails4 列名の変更

Last updated at Posted at 2014-04-02

1.マイグレーションファイル作成
rails g migration changecol_columnname

2.マイグレーションファイル編集

class ChangecolColumnname < ActiveRecord::Migration
  def change
    rename_column :target_table, :old_column, :new_column
  end
end

例:

class RenameColumnToUsers < ActiveRecord::Migration
  def change
    rename_column :users, :plan, :plan_type
  end
end

3.マイグレーション実行

rake db:migrate

4
5
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
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?