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.
Merge pull request #4395 from jaswilli/pg

Add pg as an optional dependency.