-
Notifications
You must be signed in to change notification settings - Fork 464
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
Dynamically creating and switching tenants on the fly. #172
Comments
UPDATE: Just before starting the creation of the tenant, I have made a call to restart connections
This just makes sure that the DB is looking in the right place and the connections are all correct before beginning the transaction. Hope this helps somebody else that comes across this edge case. |
I know this error. The straightforward solution I have found is to execute def within_schema
connection.schema_search_path = new_schema
yield # business staff
rescue
ActiveRecord::Base.connection.execute 'ROLLBACK'
ensure
connection.schema_search_path = previous_schema
end I do not know side-effects of this solution and can not guarantee it is right and perfect. However is works in my circumstances and allow test cases pass. |
Sorry I would like to ask about the handling on creating the tenant. The yammer subdomain is one of the "fake" tenant (which means it included all the functions and data and can work as an instance) that in charge of creating new tenant? Or it is set of specific controllers used to create tenant? I am looking for a way to do the "tenant generate console". The reason I asked that is I cannot find a way to exclude part of the controllers out of apartment. Please correct me If i am wrong. |
**Implemented enhancements:** - influitive#112 - Allow a list of schemas when switching using schemas - influitive#154 - Create schema between different versions of DB - influitive#155 **Fixed bugs:** - influitive#170 - Cache Key breaks on rails 6.0.4 - influitive#171 **Closed issues:** - Add ruby 3 to the build matrix - influitive#162 - update rubocop and fixed broken rules - influitive#157 - added junit formatter and saving test output in circle - influitive#172
This is more of a question than an issue.
I have a project that is integrating with Yammer, and where a user can sign in and if there is no schema for their current Yammer organisation then it will create one, and pull in their Yammer connections.
This all seems to work fine in dev, and I cannot recreate my issue no matter how hard I try. But things change when I get to the staging server.
Essentially these are the steps that a user goes through:
yammer.mydomain.com/callback_path
withyammer
being and excluded subdomain.The first time I ran this it worked fine. But when going through testing I can across an intermittent error.
For a while I could not even figure out how to reliably reproduce this error. But I have managed to narrow it down.
From the rails console if I call the
User.from_omniauth
call, which is the one that sets off the steps above, it will work the first time. But then if I delete that tenant and try again it will throw that error.However…
If I call
reload!
then the make the call again it will work correctly as expected.This is all fine for the console where I know I can call reload. However when running the app on the staging server I get the error above intermittently. I believe it has something to do with the way I am calling
Apartment::Tenant.switch
andApartment::Database.process
but after playing with this for a few days I have been unable to make progress.I know that it is a slight edge case. But for the product to enter production I will need to be able to resolve.
Is there any way that this sort of creation could break apartment?
The text was updated successfully, but these errors were encountered: