Make custom value repair migration work with Postgres

https://www.openproject.org/work_packages/5033