multi-tenant icon indicating copy to clipboard operation
multi-tenant copied to clipboard

Setting specific database connection for each tenant

Open suleodu opened this issue 4 years ago • 2 comments

Is it possible to have a specific database connection for each tenant ...that is what if i want my tenant A database to be hosted on another server ... i want to be able to specify the database connection name, host and password durring tenant creation

suleodu avatar Mar 18 '20 06:03 suleodu

You can specify managed_by_database_connection while creating a Website object.

https://tenancy.dev/docs/hyn/5.4/creating-tenants#managing-connection

ivanmagdic avatar Mar 18 '20 13:03 ivanmagdic

managed_by_system_connection won't quite meet your needs since it still requires a connection be defined in your database config file, and will simply use that connection definition instead of the configured "system" one when generating the tenant connection.

If you want a separate connection name for each tenant, then you'll have to define them all manually in your database config file. At this point, you're really not gaining much of anything from this package and are likely better off just building it yourself.

Having said that, I don't quite understand why you think you need separately-named connections for each tenant. Seems either overengineered, or a poor use of multitenancy

fletch3555 avatar Apr 27 '20 04:04 fletch3555