Fix the upgrade migration of custom profile fields

The upgrade_2-1_postgresql.sql changes are untested, but do match the changes to upgrade_2-1_mysql.sql that are tested and confirmed.