Fix pgsql upgrade script (sorry, it was late on saturday).

Fixes #6193