Rails 5, Rspec: Environment data not found in the schema

前端 未结 7 1210
南方客
南方客 2020-12-29 01:49

After upgrading a Rails app to Rails 5, running RSpec tests gives me the following error:

rails aborted!
ActiveRecord::NoEnvironmentInSchemaError: 

Environm         


        
7条回答
  •  生来不讨喜
    2020-12-29 02:44

    All of the above answers are correct, however, if you're in a more unique project such as developing a rails engine with a concept of a schema (hacky, I know) and your migration fails for some reason, you can re-run it without the check that throws this exception. Example:

    rake environment db:{drop,create,migrate} DISABLE_DATABASE_ENVIRONMENT_CHECK=1

提交回复
热议问题