Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to add/update users in captive breeding db #907

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

roshan-mathewtech
Copy link
Contributor

104

When a new user is create in Species+ the use need to be created with the same details in captive breeding database
Same applied when a user's password is changed in Species+ correspondingly it should update in captive breeding database application

Copy link
Contributor

@sergiomarrocoli sergiomarrocoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one comment. not sure how this all works, but seems like it could be an issue

database = Rails.env.production? ? "captive_breeding_database_production" : "captivebreeding_staging"

# Establish database connection to captive breeding database
ActiveRecord::Base.establish_connection(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm wondering if this is a good idea, or if any other database requests hitting the db at the same time will also be sent to the captive_breeding db?

this code is not thread safe. Changing ActiveRecord::Base connection affects all threads. You would need to create a new ActiveRecord::ConnectionAdapters::ConnectionPool for the additional database, then you can wrap your code in a my_conn_pool.with_connection block.

https://stackoverflow.com/questions/26574086/establish-a-connection-to-another-database-only-in-a-block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants