Implement migrations.

This pull request implements DB migrations and makes "schema.sql" the initial migration.

I also modify the test harness, which previously relied on running the statements in "schema.sql" directly, so it runs the migrations *only if they aren't up to date* to keep things fast.