anjlab / db-switch Goto Github PK
View Code? Open in Web Editor NEWSimple database connection switcher for Rails 5
License: MIT License
Simple database connection switcher for Rails 5
License: MIT License
do you have a plan to support the latest rails versions?
I have two identical tables on the same host, same login, everything, just different instances with different data. When I try to run
ActiveRecord::Base.connect_to(:replica_one) do
@project = Project.first
end
With my database.yml
looking like:
default: &default
adapter: sqlserver
host: HOST_NAME
username: USERNAME
password: PASSWORD
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: db1
replica_one:
development:
<<: *default
database: db2
The db switch does not occur. I tried printing the ActiveRecord::Base.configurations
, I get:
{
"default": {
"adapter": "sqlserver",
"host": "HOST_NAME",
"username": "USERNAME",
"password": "PASSWORD",
"pool": 5,
"timeout": 5000
},
"development": {
"adapter": "sqlserver",
"host": "HOST_NAME",
"username": "USERNAME",
"password": "PASSWORD",
"pool": 5,
"timeout": 5000,
"database": "crucible02"
}
}
There is no mention of replica_one anywhere. Is there a setup step that's missing in the README or something I'm doing wrong?
After a lot of search i found your gem for switching db connections for my slave database. But it does not seems to be working properly
Here is an example,
ActiveRecord::Base.connect_to(:replica_one) do User.first end
The above one works fine. But the below does not works. Not sure but all similar gems like octopus and others also have the same issue.
ActiveRecord::Base.connect_to(:replica_one) do User.where(id: 1) end
Any help would be greatly appreciated..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.