omero: Merge postgresql section rewrite from dev_5_0

This wasn't moved to develop yet, so here it is.