Add error handling when upgrade fails, wrap each upgrade in tx block