0

When the patch is uninstalled then the attribute is also removed from the database in the Magento 2 is it possible?

1
  • What do you mean by "the patch is uninstalled"? How do you uninstall the patch?
    – Tu Van
    Dec 13, 2022 at 7:58

1 Answer 1

0

When you created a patch most probably you have implemented Magento\Framework\Setup\Patch\DataPatchInterface if you check in Magento Framework there is another Interface Related to Patch i.eMagento\Framework\Setup\Patch\PatchRevertableInterface

if You Implement PatchRevertableInterface to you Data Patch you can implement revert() functionality as well

Like this

class YourDataPatch implements DataPatchInterface, PatchRevertableInterface
{

    /**
    * {@inheritdoc}
    */
    public function apply()
    {
       // Add code on Applying Patch        
    }

    /**
     * {@inheritdoc}
    */
    public function revert()
    {
         // Add code on Revering Patch i.e Delete Attribute
    }
}

Patch can be reverted When you Uninstall Module Remove Composer & Non-Composer Patches

Deleting Data can Create Data Inconsistency in DB so Please Do with Great Care

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.