Remove the ALTER TABLE command, this isn't needed during setup as the
buffer's getting created for the first time.
Add the CHECK constraint as seen in the upgrade script, limiting the
value of lastseenmsgid.
Add handling for lastmsgid when migrating from SQLite to PostgreSQL.
Fix 'SELECT populate_lastmsgid()' call by first resetting the query.
This fixes breakages caused by incomplete work in pull request #273.