[ticket/13303] Speed up migration dependency calculation.

[PHPBB3-13303](https://tracker.phpbb.com/browse/PHPBB3-13303)