Implement Migration.run_before

This attribute (used for reverse dependencies) was previously declared
and mentioned in the code, but never actually used.
Fixed #20550 -- Added keepdb argument to destroy_test_db
Merge pull request #2736 from SmileyChris/migration-run_before

Fixed #22725 - Migration.run_before does nothing
Rewrote migration autodetector to involve actual computer science.

Fixes #22605, #22735; also lays the ground for some other fixes.
Prevent operation pollution by later operations of fields
Fixed #22773 -- Forced templatize() to return unicode
Merge pull request #2764 from gchp/ticket-20550

Fixed #20550 -- Added keepdb argument to destroy_test_db
Fixed flake8 errors.
Added formatting and line wrapping to checks reference doc.
Removed duplicate "Deprecated in Django A.B" text in docs.

sphinx 1.2+ adds this text itself.