Use topological sort for migration operation dependency resolution

rather than an ad-hoc algorithm

The topological sort was included from https://bitbucket.org/ericvsmith/toposort
I imagine that this is preferred over creating creating a dependency.
That's a strange docstring format. Could you indent lines 7-11?