Fix typo in join condition for contact search tokens.
Condense whitespace when calculating message snippets.

Summary:
Note that this will not apply to already synced messages.

Fixes T8

Test Plan: Manual testing.

Reviewers: mg

Reviewed By: mg

Maniphest Tasks: T8

Differential Revision: https://review.inboxapp.com/D151
[SCHEMA] Save read status on Message objects; support Gmail 'unread' syncback.

Summary:
 * Add an 'is_read' bit to Message objects, which just mirrors the IMAP
   '\Seen' flag.
 * Add support for syncing back unread status changes (at a per-thread level)
   for Gmail.
 * Also tighten the nullability constraints on 'UserTagItem.created_at' and
   'UserTagItem.updated_at'. This really should have been part of migration
   028; including it here for convenience.

Test Plan: Unit tests added.

Reviewers: spang, mg

Reviewed By: mg

CC: mg

Differential Revision: https://review.inboxapp.com/D150
Set ignore_soft_deletes=False in recent migrations.

Otherwise you can't migrate databases that don't have the deleted_at column
yet.
remove this crap. too hard to understand
Eager load associated messages here rather than useless noop join.
Eager load namespaces by default.

This is a teeny tiny amount of data and we pretty much always want it.
Eager loading by default simplifies a lot of other code and reduces the
opportunity for errors caused by using joins incorrectly.
Deduplicate message download on poll too.

Notably, we don't want to re-download messages downloaded via IDLE
polling on Inbox via polling on All Mail.
Don't crash if folder monitors for account change during sync stop.
Never ignore soft deletes in mailsync sessions.

This fixes a potential bug where imapuids deleted in
check_new_g_thrids() will be soft-deleted instead of hard-deleted.
imapuids should never be soft-deleted.
Fix syncmanager_lock deadlock in Gmail sync.

Notably, this manifests when trying to run check_new_g_thrids() during
initial sync. It turns out that the code marked "XXX does this cause a
deadlock?" ...  caused a deadlock.
Fix add_new_imapuids()
Explicitly set primaryjoin on backrefs.

There's a bug in SQLAlchemy < 0.9.4 where the JOIN condition is
incorrectly generated from primaryjoin conditions which also specify
conditions intended for a backref. The fix is to make backref
primaryjoin conditions explicit.

This was causing cartesian products which OM NOM NOMd all the memory
when objects were loaded via relationships.

For more info, see:
https://bitbucket.org/zzzeek/sqlalchemy/issue/2948/better-replacement-of-columns-w-bound
add indexes to timestamp columns
filename
Use gevent.killall() instead of while loop on sync stop.

A simpler and more robust solution to my fix yesterday, inspired by
learning that killall() exists via Kavya's EAS code.
Comment talon dep for now.

Thanks to @Analect for pointing out that this doesn't work.
Can't assume that EAS tables exist in migrations.

This account backend is optional.
[SCHEMA] Fix nullable constraints on EASUid and EASFoldersync state enum.

Summary:
The former we tightened on Gmail at one point and didn't trickle it back
to EAS. The latter is a bug from way back.

We really need to figure out a better deal for what to do with EAS-only
migrations, but putting it here for now.

Depends on D153

Test Plan: Upgrade/downgrade.

Reviewers: kav-ya

Reviewed By: kav-ya

Differential Revision: https://review.inboxapp.com/D154
Ignore man/, which some pip dists use.