multi-tenant
multi-tenant copied to clipboard
Setting specific database connection for each tenant
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
You can specify managed_by_database_connection
while creating a Website object.
https://tenancy.dev/docs/hyn/5.4/creating-tenants#managing-connection
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