With the launch of Rails 6, one of the new features that was announced was for multiple DB support. This breather came to me when, in one of our applications, I was struggling to efficiently manage separate DBs. There are a number of reasons why one would want such support, such as:
- Using the SQL database for storing user data and NoSQL for location data
- Having multiple SQL databases to manage separate apps but an app might need direct access to the other DB
- Managing multiple NoSQL and Redis databases to store different kinds of data, etc.
When faced with using multiple databases, usually one serves as a master and the other servers as a slave. Because I was managing this before the release of Rails 6, I was using a not-so-optimal (read patched/hacky) way to get this done. I created a separate YAML file for the second database to store the connection information. Here is a sample file:
With the launch of Rails 6, one of the new features that was announced was for multiple DB support. This breather came to me when, in one of our applications, I was struggling to efficiently manage separate DBs. There are a number of reasons why one would want such support, such as:
Using the SQL database for storing user data and NoSQL for location data
Having multiple SQL databases to manage separate apps but an app might need direct access to the other DB
Managing multiple NoSQL and Redis databases to store different kinds of data, etc.
When faced with using multiple databases, usually one serves as a master and the other servers as a slave. Because I was managing this before the release of Rails 6, I was using a not-so-optimal (read patched/hacky) way to get this done. I created a separate YAML file for the second database to store the connection information. Here is a sample file:&nbs […]