Tenant database connection
How to set and use a tenant database connection.
Often you'd like to use a specific tenant connection without actually being in the scope of the tenant. A generic example of this while running in CLI. To solve this issue, you can set the tenant database connection as the current connection or to load a connection instance.
The tenant database connection
The database property of the website model allows for getting the connection of a tenant website easiest. It will return a DatabaseConnection instance.
The DatabaseConnection facilitates in the following:
- Setting the connection as the currently active under the default tenant connection name, used by Abstract Tenant Models.
- Getting the currently active tenant connection.
- Getting the connection of the specific tenant website.
- Checking whether the specific tenant website connection is currently active.
- Creation and deletion of tenant databases.
- Statically loading the tenant and system database connection names.
Updated less than a minute ago