Use internal DB management

Use our own internal code for managing database migrations, rather than
calling sqlalchemy-migrate's command line directly. This allows us to
automatically specify the initial version of the database, which is
required in order to be able to squash migrations (bug 1072949).

Change-Id: I88206f8b55fe6fe4016cee8e5bf1d5eeb0ae30d2