1
2

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.

テーブルにカラムを追加する(Rails)

Posted at

##既に作成されているテーブルにカラムを追加するには?

カラムを追加するマイグレーションファイルを作成する。

ターミナル
$ rails g migration Addカラム名To追加先テーブル名 追加するカラム名:

例えば、

ターミナル
$ rails g migration AddIntroductionToUsers introduction:text

その後作成されたマイグレーションファイルを確認して、

qiita.rb
$ rake db:migrate

を実行する。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?