Social Security and Migration with Endogenous Skill Upgrading