Reputation: 1841
I am building a web app (using Laravel but it's irrelevant), that will have multiple tenants with each tenant having its own database. The backend and frontend code end will be common.
We all know the benefits of multitenancy with a dedicated DB per tenant, so I will no go over it again. In my case, it fits my needs 100%.
If a tenant (client) comes to me for customization (ex. an additional feature, alteration of current feature, removal of feature, etc.) how do I execute this? Obviously I can't alter the code for all tenants, so I guess I will need some kind of filtering or settings where I can toggle features on and off per tenant.
Any ideas?
Thanks in advance.
Upvotes: 1
Views: 2404
Reputation: 362
There are couple of ways to implement Multi-Tennancy.
Here I would like to suggest two ways which I implemented previously in my projects.
First Way :
tenant
table. Add tenant_id
column in every DB table.header
part. Backend will get tenant id from header.Second Way :
tenant_name
and tenant_uuid
value.URL
like https://tenant1.xyz.com
. Create one interceptor which intercept the front end request and get tenant name
from the URL. Based on that tenant name you can get particular tenant info from DB.request context
of your application. In first way you have to pass tenant id in all layer
of application which is not advisable. But in second way you can get tenant id from context so no need to pass it in all the layer.
Now Answer for second question is :
For feature toggling of particular tenant. You can create feature table with columns feature_name
, is_enabled
and tenant_id
.
Now suppose you have to show Dashboard feature to X
tenant and do not want to show it Y
tenant. Then you just have to do enabled and disabled in this table only.
Upvotes: 3