Issue #2314289 by benjy: Track result of migrations and use it to properly define migrate_dependencies.