Fixed #22970 -- Use last migration's name in dependency to existing migrated app

Changed the autodetector to lookup the name of the existing app's last
migration in the graph and use that as dependency.