Use correct fallback in schema cache initializer #38433
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Summary
Instead of bailing when a
primarydb config is not found, attempt to load the default schema cache path.Other Information
Hopefully third time's a charm.
Originally, the schema cache initializer railtie was loading
the 'schema_cache.yml' file by hard-coding the path.
Since it's possible to override the schema cache path either by
providing an ENV variable, or by adding a configuration entry to
the database.yml config file, this means that we could potentially
end up not loading a cache that is configured to use a non-default
file.
The first attempt at fixing this (#38348) assumed that the
db config must contain a spec named 'primary'. This is not the case.
A second attempt at fixing this (#38383) bailed if no db config
was found.
This however, means that for an app without a db config named
'primary', we would not be attempting to load a schema cache
at all, even if they were using the default schema cache path.
Instead of bailing, here we go get the filename, passing a 'nil'
for the schema_cache_path, which will fall back to the default
path.