add flask-migrate to project

This adds a new 'db' command to the CLI interface. It will be used for
migrations.
move to flask-sqlalchemy

A minimal port to flask-sqlalchemy to avoid having to implement the
session handling magic.