1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib
eileencodes ee9e308f68
Default db_config should be primary or first
The handling for single database applications has always set a schema.rb
or structure.sql files for loading the database schema. When we first
implemented multiple database support we intended to keep this for the
original, default database. Afterall Rails _has_ to connect to something
on boot. In development only one connection is connected on boot since
we don't eager load the app.

Originally we had thought that all applications should be required to
add a `primary` entry in the database configurations file. However,
this hasn't worked in practice and we have some code now that does not
assume there's a primary. The schema dumping/loading code however,
still assumed there was a "primary" in the configurations file.

We want the "default" database in any application to use the original
files even when converted to a multiple database application as this
reduces the need to make changes when implementing this functionality on
an existing application.

The changes here update Rails to ensure that we treat either "primary"
or the first database configuration for an environment as "default".
If there is a "primary" that will be used as the default configuration.
If there is no primary the configuration that is first for an
environment will be used as the default. For schema dump/load this means
that the default configuration (primary or first) will use `schema.rb`
as the filename and other configurations will use
`[CONFIGURATION_NAME]_schema.rb`.

This should also help us finish the pull request to infer migrations
paths since now we can say the first configuration is the default. This
is a natural assumption for application developers.

Followup to #39536
2020-09-03 15:55:46 -04:00
..
active_record Default db_config should be primary or first 2020-09-03 15:55:46 -04:00
arel Move Arel attribute normalization into arel_table 2020-07-19 23:41:24 +09:00
rails/generators The abstract parent class file generated via generator should not be pluralized 2020-08-02 22:25:57 +05:30
active_record.rb Move advisory locks to own connection handler. 2020-08-04 10:17:41 +08:00
arel.rb Merge pull request #38719 from eileencodes/refactor-fetch_attribute 2020-03-13 16:26:49 -04:00