Fix Postgres queries in clamp database migration