When running the migration script, it gets the mediasource object based on the ID in thesource field value of the modTemplateVar object. However this is the mediasource used for the TV object itself, and not the TV value (which can be a different mediasource, as specified in the Media Sources tab on the TV update page). The migration should get the correct source ID from modMediaSourceElement, based on the TV ID, and the TV-value resource context key.