<-- Back

Data loss after deployment due to recreated domain model entities

Issue

After restoring a production backup to an environment and deploying a new package, certain entities lose their data. The data exists after restoring the production backup, but disappears after deploying the new deployment package.

Environment

Studio Pro (all versions)

Cause

When an entity or attribute is deleted during development and then recreated (rather than undoing the deletion), Mendix treats it as a completely new entity or attribute, even if the recreated entity has the same name as the deleted one. This is because the recreated entity/attribute receives a new identifier and is represented by a new database table. During deployment, the database table representing the original entity is dropped, and a brand new table is created for the recreated entity, resulting in data loss.

Solution/Workaround

To identify and resolve domain model changes causing data loss during deployment, consider the following tools:

  1. Compare domain model changes using version control:
    • Open two instances of Studio Pro side by side
    • Create a new branch from the specific revisions to compare in each instance
    • View the exact changes made in the domain model between versions
  2. Review version control history:
    • In Studio Pro, navigate to Version Control → History
    • Review all revisions or commits on the relevant branch
    • Look for changes in the domain model, specifically any entities that were deleted and then re-added with the same name
  3. Verify the cause using database backup comparison:
    • Take a backup of the environment after restoring production data, but before deploying the new package
    • Take another backup after deploying the new package
    • Restore both backups locally in pgAdmin
    • Execute queries to compare the number of rows in affected tables
    • Compare the data before and after deployment to confirm the new deployment package contains problematic domain model changes
  4. Fix the issue:
    • Identify entities that were deleted and recreated, then revert these changes and commit in version control
    • Instead of recreating entities, always undo deletions to preserve the original entity identifier and database structure
    • Create a new deployment package with the corrected domain model
  5. Alternative diagnostic approach:
    • Run the application/project package locally via pgAdmin
    • Restore the backup to view the SQL commands being executed during deployment
    • This can help identify which tables are being dropped and recreated

Important: Mendix does not provide a domain model locking feature to restrict entity modifications to specific users. Development teams should establish processes to prevent accidental deletion and recreation of entities, and always undo changes rather than recreating entities when mistakes occur.

Internal information related

  • 256012

Additional information

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.

To provide feedback, please open a ticket here. Don't forget to include the article's URL along with the feedback you would like to provide.