Helping you drive digital innovation
Subscribe
RSS Feed of the Mendix Blog
Thanks for Subscribing

Keep an eye out for Mendix resources coming straight to your inbox.

Keep your data safe

on April 24, 2012

Share:

Domain model changes lead to updates of the database. For example, when you add an entity to a domain model, a table is automatically created in the database the next time that you deploy your project. Creating attributes in the model leads to columns in the database and associations lead to link tables. Deleting elements from the domain model result in database altering (DDL) commands that, when executed, will delete tables and columns. As explained in an earlier tech-tip, you should not edit the database by hand.

In Mendix 3.0 and above, entities, associations and attributes are internally identified by a unique number instead of a name. This helps us to keep track of creates, renames and deletes much better than in version 2.5. It does have some consequences of which you need to be aware:

  1. If you delete an entity called ‘Customer’ and then create an entity with the exact same name, DDL commands will be generated that delete the customer table! So if you accidentally delete an entity, do not create a new entity with the same name but use ‘Undo’ or the version control ‘Revert change’ feature to get it back. This will give you back the entity with the same unique identifier and data will be retained.
  2. When importing a new version of an App Store module, you get the option to replace an existing module. Please use this option if you want to retain the data that the module manages. The replace option performs a name-based synchronization of the unique identifiers of the imported module with the existing module. In short, do not delete a module and then add a new version but replace it instead.
  3. If you want to move an entity to another module, you should not delete the entity and re-create it in the other module; use the ‘Move to’ feature instead. You can find this feature in the context-menu of an entity. The move will also move associations and convert them to cross-module associations or the other way around if necessary, all while retaining data in the database.

The common theme of this post is that deleting domain model elements or whole modules will delete all corresponding data in the database, even if you re-create something with the same name. Use one of the offered alternatives to keep data intact and check the DDL commands when deploying to an environment with valuable data!

Tags:

Subscribe to Our Blog

Receive Mendix platform tips, tricks, and other resources straight to your inbox every two weeks.

RSS Feed of the Mendix Blog
Arjan van IJzendoorn

About Arjan van IJzendoorn

Arjan is a member of the Mendix R&D department. He started developing the Mendix Modeler a long time ago and is still working on that application most of the time. Currently, he focuses on the modeling side of pages and widgets, with the occasional excursion into the rest of the Modeler.

| Community Profile