LoginSignup
5
5

More than 5 years have passed since last update.

FactoryGirl周りでrake db:migrateがこける場合

Posted at

be rake db:migrate RAILS_ENV=developmentが以下エラーを吐いてこけるので原因を調査。

ActiveRecord::StatementInvalid: Mysql2::Error: Table 'polaris_db2.leveled_experiences' doesn't exist: SHOW FULL FIELDS FROM `leveled_experiences`

workaround

取り敢えずdevelopmentからfactory_girl_railsのgemを外すだけでdb:migrateは通るようになった

根本原因は?

この回答を引用すると、{}でくくり遅延評価属性を利用しないといけないものがあったみたい、もう少し基礎知識つけないとなぁ

Factory.define :hat do |h|
  h.person { Factory(:person) }
end

参考
RSpecにおけるFactoryGirlの使い方まとめ

Railsのrake db:xxxコマンドでtable doesn't existのエラーが出る際の対処

FactoryGirl screws up rake db:migrate process

5
5
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
5
5