Build migration map and handle migration errors