You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an application that has been running with apartment with postgresql adapter in use_schemas-mode and it's been working for years. By tenants are based on country, splitting my application by country.
In order to scale the application we need to start splitting the database into multiple hosts (physical servers). I am trying to make this work using apartment, but so far it fails. I have an apartment config like this:
Apartment.configuredo |config|
config.excluded_models=["User","CustomerUser","Payment::Order","PaymentNotification","Payment::OrderDiscount","ModelText","EmailResponse"]config.use_schemas=trueconfig.use_sql=trueconfig.persistent_schemas=['extensions']config.prepend_environment=falseconfig.append_environment=falseconfig.default_schema="da"tenant_config={}{1111=>%w[deatsefinlno],2222=>%w[itplesptrodaukchfr]}.eachdo |port,schemas|
schemas.eachdo |tenant|
tenant_config[tenant]={adapter: 'postgresql',host: 'localhost',port: port,database: 'postgres'# this is not the name of the tenant's db# but the name of the database to connect to, before creating the tenant's db# mandatory in postgresql}endendconfig.with_multi_server_setup=trueconfig.tenant_names=tenant_configend
Now when I try to do Apartment.switch!('de') I get:
Apartment::TenantNotFound: One of the following schema(s) is invalid: "de" "da", "extensions"
Caused by ActiveRecord::StatementInvalid: Could not find schema de
Why is this happening? Is there something I have overlooked?
The text was updated successfully, but these errors were encountered:
The research that I have done seems to indicate that use_schemas is incompatible with with_multi_server_setup
There is a note about it in this issue: #596, but I also went and traced through the code and found that use_schemas causes use of a different postgres adapter, which overrides the connect_to_new method.
I am in the same situation as you, and it is imparitive that my organization finds a solution to this issue. I will report back when I find a work around.
In the mean time, can we get some input from the maintainer ( @mikecmpbll ) about this issue?
I have an application that has been running with apartment with postgresql adapter in
use_schemas
-mode and it's been working for years. By tenants are based on country, splitting my application by country.In order to scale the application we need to start splitting the database into multiple hosts (physical servers). I am trying to make this work using apartment, but so far it fails. I have an apartment config like this:
My database.yml looks like this:
Now when I try to do Apartment.switch!('de') I get:
Why is this happening? Is there something I have overlooked?
The text was updated successfully, but these errors were encountered: