Print Page | Close Window

Model migration after property type change

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: https://www.metacase.com/forums/forum_posts.asp?TID=932
Printed Date: 27.Mar.2026 at 03:35
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: Model migration after property type change
Posted By: jarno.leikas
Subject: Model migration after property type change
Date Posted: 17.May.2021 at 11:11
Hi,

This has probably been asked before, but couldn't find a topic with the Search.

I'd like to change a property type from a Boolean to a Fixed list. We have a number of existing models that we need to migrate so that a Checked checkbox is migrated to a particular selection in the Fixed list.

I know I can use the API to do the migration, but was looking for a method that would involve the minimum number of metamodel patches (and steps in general). I've identified the following options:

"External backup"
1) Use the API to "backup" the old values from the model - disk, keep in memory, whatever.., 
-> QUESTION: If I export the model as an MXM, I can see the Boolean property and its values inside an object element with an Id - can I rely on the containing object's id to remain the same? 
2) Then patch the model with a new .MET
3) Finally migrate the old Boolean values back to the model using API

This would involve one .MET patch, but would require an intermediate storage for the old Boolean values (generate a file with the API or use an .MXM export)

New property with intermediate patch
1) Patch the model with an "intermediate" metamodel, which contains BOTH the Boolean field AND the Fixed list
2) Use the API to migrate the Boolean fields' values to the new Fixed list fields' values
3) Patch the model with the "final" metamodel, which ONLY contains the Fixed list property

This would involve 2 .MET patches, but wouldn't require any intermediate storage for the old Boolean values, as they are safe in the model.

QUESTION: Is there an approach possible in MetaEdit+ that I've overlooked completely? 



Replies:
Posted By: stevek
Date Posted: 17.May.2021 at 12:03
Either approach is fine. In most cases, I'd find it easiest to obtain a list of all instances of this type and their Boolean value by using MERL, but if you're handy with XML queries that can work too. If you want to keep things simple, aim to get all the graphs in one file. If you have a top-level graph whose subgraph tree includes all graphs, that's easy enough to script (filename id '.mxm' print, as part of a generator or with https://metacase.com/support/55/manuals/mwb/Mw-10_2.html#:~:text=textformERL:" rel="nofollow - textForMERL: ). If there isn't an all-encompassing tree, you can export all graphs with  https://metacase.com/support/55/manuals/mwb/Mw-10_1.html#:~:text=exportName:type:file:" rel="nofollow - exportName:type:file:  and * wildcards for the first two arguments.

"External backup"
  1. Within a given repository, an object's oid will stay the same. The MXM shows the oid as an attribute, and also uses the same value as the XML element id. The latter is only present when the same element is referred to from another element's href attribute, so you can't necessarily rely on its presence: use the oid attribute.
I don't see a way to beat three steps: you need to read the old values, update the metamodel and write the new values. The fastest execution time in most cases will be with External backup and MERL rather than MXM.


Posted By: jarno.leikas
Date Posted: 17.May.2021 at 12:31
Thanks, 

The execution time here (in terms of program execution time) fortunately makes little difference in these models. I think I'll do it via the MXM route, as I can read the XML with C# easily enough.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.05 - http://www.webwizforums.com
Copyright ©2001-2022 Web Wiz Ltd. - https://www.webwiz.net