I have a meta field declared as a ShortString in an already running Commerce solution. Now it turns out, that the type should have been LongString instead, and I therefore would like to change it from code (I create all Commerce meta fields from code on startup).
I see that the static class MetaField has a Delete and a Create method, but I don't want to remove the existing meta field and it's data from production. I merely want to do a change of the datatype from ShortString -> LongString. Thus I'm missing a method called something like MetaField.ChangeExisting(...).
Can this change of meta data type be done in a running solution?
Alternatively, I will have to create a new field of type LongString, and abandon the old field.
No there is no way to do it. I would suggest to add new metafield (even better, new Property) then migrate data from the old one. You can probably write a scheduled job that iterate over the contents then copy the property over. After that you can drop the old property.