Skip to content

Conversation

@kytrinyx
Copy link
Contributor

Summary

Instead of bailing when a primary db 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.

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.
@rafaelfranca rafaelfranca merged commit 6138aa6 into rails:master Feb 11, 2020
@kytrinyx kytrinyx deleted the schema-cache-default branch February 11, 2020 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants