Migrating doctype to different app

I have custom application A and application B. I want to move all doctypes and customisations from application A into B and then uninstall application B.
What’s the safest way/steps to do this migration in a safe way so that in don’t loose all data in database table with those doctypes.