How is your experience with the OutSystems Community?
19
Views
1
Comments
Multi-Tenant Data Merge Strategy in OutSystems
Discussion

Problem Statement

Our application has been running as a multi-tenant OutSystems solution for several years. Each tenant's data is isolated through the built-in Tenant Identifier mechanism.

A new business requirement has emerged where data from Tenant A must be merged into Tenant B. After the merge, all records belonging to Tenant A should become part of Tenant B while maintaining data integrity and relationships.

Challenges

  • Tenant data is isolated by OutSystems.
  • Multi-tenant entities are normally accessed only within their respective tenant context.
  • Parent-child relationships must remain valid after migration.
  • Foreign key references must not be broken.
  • Data consistency and auditability must be maintained throughout the migration process.

Proposed Solution

So we are going to create a dedicated Tenant Migration Tool implemented in a non-multi-tenant module.

Approach

  1. Create a new non-multi-tenant application/module.
  2. Reference the required multi-tenant entities from existing applications.
  3. Expose entities with write access instead of read-only access.
  4. Since the module is non-multi-tenant, it can access records across all tenants and view the Tenant Id associated with each record.
  5. Update the Tenant Id of selected records from Tenant A to Tenant B.
    exp: 

    UPDATE TableA

    SET Tenant_Id = 334 WHERE Tenant_Id = 335;

  6. Execute migration in the correct dependency order to preserve foreign key relationships.
  7. Perform validation and reconciliation after migration.

    I would appreciate feedback on this approach. Specifically, I would like to know if there are any risks, limitations, or technical concerns that I may have overlooked. Additionally, if there are more robust or recommended alternatives for handling tenant consolidation and data migration in OutSystems, I would be interested in understanding those approaches and the advantages they provide over directly updating the Tenant Identifier. 
2021-05-14 21-28-05
André Machado

Your approach is technicaly possible in OutSystems 11 and using a separate non multi tenant administration module is fine.

However, cross tenant access only happens after enabling show/expose TenantId on the consumed entities. Once enabled, automatic tenant isolation is disabled for those entities so every query and write must explicitly filter or assign the correct TenantId.

Updating TenantId keeps the application record Ids unchanged but it should not be considered a complete tenant merge. You need to check unique key conflicts, duplicate data

Freeze writes during the migration and keep an audit and rollback log and after that validate table coutns, relationships, and orphan records

If Tenant B is empty and there are no conflicts, a controlled TenantId update may be reasonable. For overlapping data, copying, mapping, and deduplicating records is safer. For production, I would also validate the plan with OutSystems Support.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.