Versioning and transaction management for PostgreSQL