12
11

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のrake db:xxxコマンドでtable doesn't existのエラーが出る際の対処

Last updated at Posted at 2015-01-31

##問題点

$ bundle exec rake db:migrate
$ bundle exec rake db:schema:load
$ bundle exec rake db:test:prepare
etc...

といったDBセットアップ用のrakeタスクを実行した際に

rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: Table '(テーブル名)' doesn't exist: SELECT `(テーブル名)`.* FROM `(テーブル名)`
...

とエラーが出てrakeタスクが中断されてしまいました。

##解決策

詳細は不明ですがfactoryファイルが原因だったみたいです。

spec/factories/を一時的にどっかに退避させておいて

$ bundle exec rake db:schema:load
#他コマンドでもok!

とかすると無事テーブルが作成されました

なんか釈然としませんが同じような症状の人の助けになれば(´・_・`)

12
11
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
12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?