File tree Expand file tree Collapse file tree 4 files changed +25
-0
lines changed
railties/lib/rails/generators/rails/app/templates/config/databases Expand file tree Collapse file tree 4 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,13 @@ production:
8686 replica: true
8787` ` `
8888
89+ NOTE : In the same way that it's possible to [configure](configuring.html#configuring-a-database)
90+ the primary database by setting the connection string in the `DATABASE_URL` environment variable,
91+ it's possible to configure other databases using an environment variable prefixed with the
92+ configuration key in uppercase. For example, setting :
93+ ` ANIMALS_DATABASE_URL="mysql2://username:password@host/database"` overrides the `animals`
94+ configuration in the "production" environment.
95+
8996When using multiple databases, there are a few important settings.
9097
9198First, the database name for `primary` and `primary_replica` should be the same because they contain
Original file line number Diff line number Diff line change 4949# production:
5050# url: <%%= ENV["MY_APP_DATABASE_URL"] %>
5151#
52+ # The connection URL for non-primary databases can also be configured using a
53+ # similar environment variable prefixed with the configuration key in uppercase.
54+ # For example:
55+ #
56+ # CACHE_DATABASE_URL="mysql2://cacheuser:cachepass@localhost/cachedatabase"
57+ #
5258# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
5359# for a full overview on how database connection configuration can be specified.
5460#
Original file line number Diff line number Diff line change 8181# production:
8282# url: <%%= ENV["MY_APP_DATABASE_URL"] %>
8383#
84+ # The connection URL for non-primary databases can also be configured using a
85+ # similar environment variable prefixed with the configuration key in uppercase.
86+ # For example:
87+ #
88+ # CACHE_DATABASE_URL="postgres://cacheuser:cachepass@localhost/cachedatabase"
89+ #
8490# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
8591# for a full overview on how database connection configuration can be specified.
8692#
Original file line number Diff line number Diff line change 5151# production:
5252# url: <%%= ENV["MY_APP_DATABASE_URL"] %>
5353#
54+ # The connection URL for non-primary databases can also be configured using a
55+ # similar environment variable prefixed with the configuration key in uppercase.
56+ # For example:
57+ #
58+ # CACHE_DATABASE_URL="trilogy://cacheuser:cachepass@localhost/cachedatabase"
59+ #
5460# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
5561# for a full overview on how database connection configuration can be specified.
5662#
You can’t perform that action at this time.
0 commit comments