[ticket/11383] Correctly revert modules added/removed by migrator

This should fix issues where migrator cannot remove module categories, for extensions that add a module category, as it started reverting from the module category instead of starting from the module mode and move upwards 

PHPBB3-11383