Refactor PostgreSQL adapter