I got it working by giving the espocrm user superuser privileges for the update and revoking it afterwards.

Code:
psql postgres
postgres=#
...