Add pg as an optional dependency.

Closes #1333
- Change PostgreSQL build on Travis from an allowed failure to
  failing the tests just like sqlite3 and MySQL.