Fix lost FileDiffs when using condensediffs on Postgres.
Fix lost FileDiffs when using condensediffs on Postgres.

The condensediffs management command was trying to determine whether a
more efficient update can be performed for batch-updating FileDiffs when
migrating to the new diff storage format. However, the way it was doing
this was only compatible with MySQL, resulting in it falling back to the
slower method for Postgres.

Unfortunately, the slower method also failed to update entries on
Postgres, and this would result in FileDiffs retaining their relations
to the old objects. Those objects would then be deleted, deleting the
FileDiffs as well, which is a pretty serious bug. Somehow, we haven't
heard of this in the wild (and it only happens explicitly with
condensediffs).

This fixes this by both fixing the cause of the failed updates (a bad
"__in" that works in SQLite but not Postgres) and by getting rid of the
"generic" check for the smarter updating, replacing it with specific
code for MySQL and for Postgres.

Condensing also now performs sanity-checks when DEBUG is True, to help
us catch issues sooner.

Testing Done:
Tested on MySQL, Postgres, and SQLite, with large numbers of diffs.
Verified that the diffs had the expected content in the end. The
sanity checks also passed.

Reviewed at https://reviews.reviewboard.org/r/8161/

davidt/reviewboard,reviewboard/reviewboard,sgallagher/reviewboard,chipx86/reviewboard,davidt/reviewboard,reviewboard/reviewboard,brennie/reviewboard,sgallagher/reviewboard,chipx86/reviewboard,brennie/reviewboard,brennie/reviewboard,chipx86/reviewboard,brennie/reviewboard,reviewboard/reviewboard,sgallagher/reviewboard,davidt/reviewboard,davidt/reviewboard,chipx86/reviewboard,reviewboard/reviewboard,sgallagher/reviewboard