Model migration after property type change |
Post Reply |
Author | |
jarno.leikas
Member Joined: 27.Apr.2021 Location: Jyväskylä Points: 6 |
Post Options
Thanks(0)
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?
|
|
stevek
MetaCase Joined: 11.Mar.2008 Points: 641 |
Answer Post Options Thanks(0) |
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 textForMERL:). If there isn't an all-encompassing tree, you can export all graphs with exportName:type:file: and * wildcards for the first two arguments.
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.
|
|
jarno.leikas
Member Joined: 27.Apr.2021 Location: Jyväskylä Points: 6 |
Post Options
Thanks(0)
|
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.
|
|
Post Reply | |
Tweet |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |