LoginSignup
79
65

More than 5 years have passed since last update.

Rails:migrateでDBをリセットして最初からつくり直す方法。

Last updated at Posted at 2018-10-01

開発途中にDBを全てリセットをする必要があったため、
備忘録を含め記録として残したいと思います。

①全てのレコードを空にしたい場合はrake db:resetを行う。

rake db:resetは全てのテーブルを dropし、"db/schema.rb"を元にテーブルの再作成を行います。

"db/migrate/" 以下の全ての migration を実行してテーブルを再作成したい場合は、rake db:migrate:reset

全てのテーブルを dropし"db/migrate/"以下の全ての migration を実行してテーブルを再作成を行うため、こちらの方が効力が強いかと思料されます。

ご参考になれば幸いです。

79
65
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
79
65