0
0

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

Railsで使用するテーブルの型の種類について

0
Posted at

Railsで使用するテーブルの型の種類について

  • テーブルの作り方
作る例
$ rails g model User name:string

$ rails g model モデル名 カラム名:型

消す例
$ rails d model User

$ rails g model モデル名

指定できる型の種類

  • string : 文字列
  • text : 長い文字列
  • integer : 整数
  • float : 浮動小数
  • decimal : 精度の高い小数
  • datetime : 日時
  • timestamp : タイムスタンプ
  • time : 時間
  • date : 日付
  • binary : バイナリデータ
  • boolean : Boolean

マイグレーション実行方法

このままだと、実際のDBには反映されないので、db:migrateコマンドを実行しないといけない

$ rails db:migrate
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?