Can an existing entity, which has referential integrity constraint, be converted into a multi tenant entity? My entity is referenced by several entities, is it feasible and possible to change the multi tenancy behavior without breaking the code? If yes, what is the best way to achieve this? 

Hi Mishika,

yes you can whitout any data lose. once you convert your entity to multi tenant there is only one entity attribue add tenantid to all corrosponding data and assign defalut value of tenant .

If you want change existing entity to multi tenant there a way double click on entity and go to advance tab and click on yes - is multi tenant 


May be somewhere it will break code, like Advance sql.


Hope this will help you.

Ragards

Rahul Sahu

Hi Mihika,

Multi-tenancy is a very powerful feature of Outsystems and it is not just limited to making your entities but there are other elements like users,Site properties , Timers and BPT process can also be set to  multi tenant and hence it is very importnat to first understand how multi-tenancy works in Outysytems.

You can also have non multi-tenant and multi-tenant entities in the same application but while executing your queries you need to make sure that proper filters are being used .

Please go through this link for more understanding.

https://success.outsystems.com/Support/Enterprise_Customers/Maintenance_and_Operations/How_to_Build_a_Multi-tenant_Application

Any additional information will also help me to provide better solution for your quesries.


Regards,

-PJ-

Thanks Rahul and Pramod,

I have other multi tenant entities in my application which are working as expected. This entity (Entity A) was originally a single tenant entity, The data from this entity is stored in other multi-tenant entity (Entity B) as reference, If I convert A to multi-tenant the data stored in B will be pointing to a non existent data for the other Tenant. How do I circumvent this?

Hi Mishika,

I tried reproducing the same scenario at my end and what is happening here is , changing entity to multi-tenant will add the Tenant_id column to your entity and insert the value of default tenant_id (User tenant ) in that column. I also observed the data which was inserted as foreign key to other multi-tenant remain same there in that table .

Other option i see to have your data consistence , if you are doing it in development environment cleanup all the data from you entities and than change and publish your entities again.

I am trying some more scenario and will share the results with you soon.

Regards,

-PJ-

Hi Mishika ,

Here is some more explanation with example.

You have two Tenants (User - Default Tenant - id:20) and (TestTenant- Your Tenant- id:21) 

Now you have two entities Entity A and Entity B like shown below (have populated some data as well for example)

Entity  A
Column1-PrimaryKeyColumn2Column3
101Data 1Test 1
102Data 2Test 2
103Data 3Test 3
104Data 4Test 4


Entity B (Multitenant)
Tenant_IdColumn1Column2Column3-Foreignkey-Entity  A
21Test DataTest Data101
21Test DataTest Data102
21Test DataTest Data103
21Test DataTest Data104


In this situation the value of the Column3 in Entity B will be visible through Entity A by putting a join condition.

Now if we change the first entity to Multi-Tenant the data in the table will be updated like below.

Entity  A
Tenant_IDColumn1-PrimaryKeyColumn2Column3
20 (Default Tenant)101Data 1Test 1
20 (Default Tenant)102Data 2Test 2
20 (Default Tenant)103Data 3Test 3
20 (Default Tenant)104Data 4Test 4


And after this change if you run the existing query on Entity B where you have data from other tenant , the data fro Column3-ForeignKeyFromA  value will not be visible as the tenant id is different.


Regards,

-PJ-