New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails 6.0.0.beta1 can not load database configuration when the URL (or database) is nil #35091
Comments
Seems to happen when |
Somehow this caused a test suite fail in CircleCI. The logs were stating a fail to read database configuration for |
Given that URL configurations do this, I think this use-case is no longer supported. There's special code for cc @eileencodes |
Eh that wasn't true, I forgot I implemented the ability to use |
ActiveRecord::Base.configurations.configs_for(env_name: "development") =>
ActiveRecord::Base.configurations.configs_for(env_name: "production") =>
I would expect something like this instead of
|
I'm confused, why are you using the production configuration if the database url isn't set? |
Actually I noticed the changing behavior when I'm trying to make a deploy to Dokku. After the Rails 6.0.0.beta1 upgrade, during the
We have never changed the |
Ok I was able to reproduce this and am working on a fix. One thing I'd like clarification on is I'm guessing the beta in 5.2 doesn't blow up but doesn't work either because without the database url it would not be able to connect right? Can you tell me what happens with the beta connection in 5.2.2? Thanks! |
Previously if the `url` key in a config hash was nil we'd ignore the configuration as invalid. This can happen when you're relying on a `DATABASE_URL` in the env and that is not set in the environment. ``` production: <<: *default url: ENV['DATABASE_URL'] ``` This PR fixes that case by checking if there is a `url` key in the config instead of checking if the `url` is not nil in the config. In addition to changing the conditional we then need to build a url hash to merge with the original hash in the `UrlConfig` object. Fixes rails#35091
Steps to reproduce
Here is a part of the database configuration we use:
In Rails 5.2.2 when I call
ActiveRecord::Base.configurations['production']
it returns:However, in Rails 6.0.0.beta1
ActiveRecord::Base.configurations['production']
it returns:Expected behavior
ActiveRecord::Base.configurations
should return the existing database variables as it was in Rails 5.2.2.Actual behavior
Rails 6.0.0.beta1 returns
nil
when theurl
(ordatabase
) isnil
somehow.System configuration
Rails version:
Ruby version:
Tested with both:
The text was updated successfully, but these errors were encountered: