Read More
Read More
Menu Close

    Uninstaller in Magento 2

    Magento 2, provides a great feature of Uninstalling the module. Sometimes, we need to remove the complete data of module installed during the installation process. As we can create tables and attributes with InstallData and InstallSchema we can also remove tables as well as attribute with Uninstaller script.

    Note: Uninstaller at present only works for the module downloaded with composer. Also, Uninstaller script works fine on Magento v2.2.0, earlier versions were having issues during module uninstallation.

    First we will install a TEST module through composer and then we will Uninstall to check it is working. For this I am using this repo Webkul_UninstallerTest.

    To install the sample module you need to include this module in your composer.json file. In composer.json file in require section add the following code.

    "webkul/uninstaller_test": "dev-master"

    Now, in repositories section in composer.json file add the following code.

    Searching for an experienced
    Magento 2 Company ?
    Read More
    "type": "vcs",
    "url": ""

    After adding the entry in composer.json,  run the following command

    php bin/magento composer install

    Now, your module is installed in vendor directory. Composer install just download the code from git, you need to run php bin/magento setup:upgrade for installation of module.

    In the module, we have created a table. Now, when we will run Uninstaller command all the data and the table will be removed.
    For Uninstalling the module, we need to run

    php bin/magento module:uninstall Webkul_UninstallerTest

    On successful Uninstall you will get the following message:

    Removing data of Webkul_UninstallerTest
    Removing Webkul_UninstallerTest from module registry in database
    Removing Webkul_UninstallerTest from module list in deployment configuration
    Removing code from Magento codebase:
    Cache cleared successfully.
    Generated classes cleared successfully. Please run the 'setup:di:compile' command to generate classes.
    Info: Some modules might require static view files to be cleared. To do this, run 'module:uninstall' with the --clear-static-content option to clear them.
    Disabling maintenance mode

    Now, if you will check the database table wk_test created during module installation is removed. For more information regarding Uninstaller you can refer to Magento Doc.

    That’s all for this post, will be back with Uninstaller script removing the created attributes. If you have any query, please comment below.

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*

    Be the first to comment.

    Back to Top