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.

【備忘録】Ruby on Rails でDBにカラムを追加する

Posted at
1 / 2

Rails初心者がDBの扱いの基本を備忘録として書いていきます。

〇やりたい事
・tasksというテーブルにDate型のDeadlineという名のカラムを追加する。

##手順1 Rails DBConsole起動

$rails dbconsole

##手順2 スキーマでテーブルの中身を確認

sqlite> .schema

##手順3 .exitでdbconsoleを抜ける

sqlite> .exit

##手順4 rails g migration AddTo〇〇の構文でカラムを追加

rails g migration AddDeadlineTOtasks Deadline:date

参考記事
https://qiita.com/ai_qiita/items/9c28d0c161f845b9e9a6

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?