Trigram migration

Okay, here's my first pass at getting this done. Feedback very welcome.

Fixes #35.