updating image migration stored proc to work with older versions of mysql