Use topological sort for migration operation dependency resolution

rather than an ad-hoc algorithm
Merge pull request #3525 from vanschelven/master

Use topological sort for migration operation dependency resolution