Document multiple databases in Rails#36389
Conversation
|
❤️ |
jhawthorn
left a comment
There was a problem hiding this comment.
Great! Would it make sense to have a section explaining how to use connected_to(role: ...)?
Ah yes I knew I was forgetting something. |
49a94ef to
b0d1d7f
Compare
|
Updated the guides with |
b0d1d7f to
a047405
Compare
|
Updated to include a section about migrations. |
There was a problem hiding this comment.
Shouldn't it include example of migrations_paths config as well?
There was a problem hiding this comment.
Added migrations_paths, however I think we don't actually need them anymore. But dealing with that is for another day 😄
There was a problem hiding this comment.
For simplicity shouldn't it inherit from ActiveRecord::Base?
There was a problem hiding this comment.
Simplicity of the app or of the example? If you don't inherit from ApplicationRecord you'll end up having to rewrite everything you rely on for all your models that is in ApplicationRecord.
There was a problem hiding this comment.
simplicity of example ;-)
if it inherits from ApplicationRecord, then self.abstract_class = true is redundant.
Anyway, not a big deal - I guess it's quite clear what is going on in both versions
a047405 to
a7a626b
Compare
There was a problem hiding this comment.
simplicity of example ;-)
if it inherits from ApplicationRecord, then self.abstract_class = true is redundant.
Anyway, not a big deal - I guess it's quite clear what is going on in both versions
There was a problem hiding this comment.
isn't there replica: true missing?
There was a problem hiding this comment.
If it's replica, does it also need migrations_paths?
There was a problem hiding this comment.
"in order to use the read-only replica", maybe?
"to use multiple databases" sounds a bit too generic: that would equally describe e.g. a primary + animals setup, which doesn't need any switching.
This file documents how to use multiple databases, what features are supported, what features are coming soon, and caveats.
a7a626b to
8574c3e
Compare
Document multiple databases in Rails
|
|
||
| First, the database name for the primary and replica should be the same because they contain | ||
| the same data. Second, the username for the primary and replica should be different, and the | ||
| replica user's permissions should be to to read and not write. |
| ```ruby | ||
| config.active_record.database_selector = { delay: 2.seconds } | ||
| config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver | ||
| config.active_record.database_resolver_context = MyCookieResovler |
…ses with Active Record(rails#36389) [ci skip]
This file documents how to use multiple databases, what features are
supported, what features are coming soon, and caveats.
Do you think I'm missing anything important?
cc/ @tenderlove, @matthewd, @rafaelfranca, @jhawthorn