In that scenario, systemctl is-enabled UNIT can be used. The exit status will give if the unit is enabled or not on the system and then, according to the exit status, you do the transition or not. You would have something like:
if systemctl is-enabled OLD_UNIT then
systemctl stop OLD_UNIT
systemctl disable OLD_UNIT
systemctl enable NEW_UNIT
systemctl start NEW_UNIT
endif
Repeat for each unit that needs a transition. Maybe put a for loop if wanted.