solidusio / solidus

🛒 Solidus, the open-source eCommerce framework for industry trailblazers.
https://solidus.io
Other
4.98k stars 1.29k forks source link

Improve developer experience when changing payment methods. #3802

Open kennyadsl opened 3 years ago

kennyadsl commented 3 years ago

It happens that stores change their payment method over the years. When switching to a new extension it's a good practice to remove the old one once the migration is done. But by doing so, we'll have a lot of references in the database that points, through STI, to a class that doesn't exist anymore.

When this happens, we should find a way to avoid the application to raise an exception similar to:

ActiveRecord::SubclassNotFound (The single-table inheritance mechanism failed to locate the subclass: 'Solidus::Gateway::BraintreeGateway'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Spree::PaymentMethod.inheritance_column to use another column for that information.)

I'm not sure it's possible, I'd make an attempt to explore some possible solutions though.

Solidus Version: All solidus versions

To Reproduce

See this issue as an example: https://github.com/solidusio/solidus_paypal_braintree/issues/184

Additional context

An alternative could be documenting best practices for switching from a payment method to another in our guides, in order to point users to a good resource when they are facing this scenario.

peterberkenbosch commented 3 years ago

@kennyadsl this has been on my radar as well here: https://github.com/solidusio-contrib/solidus_affirm_v2/issues/9