Update migration 072 to not depend on Message model.

The problem is that a later migration (076) adds a Message.thread_order column.
So if you try to run a migration that spans 072 to 076, it will import the
later version of the Message class, which references a thread_order column that
isn't in the database yet. Fix this by including a self-contained
calculate_html_snippet function.

Also update migration 079 to properly check for the existence of the 'uid'
unique constraint.