简体   繁体   中英

rails test table doesn't exist after reverting migration

this is a very silly question I think: I just removed a table named person_emails I created a minute ago in a new demo app I created half an hour ago. Then I started testing like just now, when I ran a unit test on an unrelated model called line_item, and I got "ActiveRecord::StatementInvalid: Mysql::Error: Table 'depot_test.person_emails' doesn't exist: DELETE FROM person_emails "

I did do the rake db:test:prepare and rake db:migrate RAILS_ENV=test.

Also, I had this column named "price" in the line_items table which I used a migration to remove, but the test tests for it anyway and throws and error. Is there something that I always should do for tests after reverting a migration or using a migration to remove a column?

Any ideas?

Thank You!

I'm pretty sure this is happening because you still have a person_emails fixture file! It's trying to clear the table before it loads the fixture data. Check for a file called test/fixtures/person_emails.yml and delete it, and you should be set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM