Skip to content

How to convert old script to declarative schema / data patch without breaking any data?

I have a module (v1.0.1) with an InstallSchema to create a table and an InstallData to create a product attribute.

Now I want to update the module (v1.0.2) to convert the InstallSchema to the declarative schema (for table creation) and InstallData to Data Patch (for attribute creation).

My question here is:
How do we perform the upgrades safely for the customers who are already using v1.0.1 and want to upgrade to v1.0.2? so that there are no errors like table/column/attribute already exists