The Subscription Cancel integration allows upsells to be used to upgrade subscriptions. This is a built-in integration, you can set this up directly from the Integrations tab in the Product Settings.
How To Set Up A Subscription Cancel Integration
Go to the Integrations tab in your Product Settings and select Subscription Cancel from the Services menu. Then select the product you want to cancel when this product is purchased as an upsell.
In the example below the following will occur from the settings chosen. When Product 1 is purchased as an upsell, Product 2 will be cancelled immediately.