MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Model migration after property type change
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Model migration after property type change

 Post Reply Post Reply
Author
Message
jarno.leikas View Drop Down
Member
Member


Joined: 27.Apr.2021
Location: Jyväskylä
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote jarno.leikas Quote  Post ReplyReply Direct Link To This Post Topic: Model migration after property type change
    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? 
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 641
Answer Answer
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post 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 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.

"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.
Back to Top
jarno.leikas View Drop Down
Member
Member


Joined: 27.Apr.2021
Location: Jyväskylä
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote jarno.leikas Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.063 seconds.