6

When using M1 i could reinstall the extension (launch setup/upgrade) just deleting the extension recording from the core_resource table. During the second magento address (or after cache refreshing) the extension executed all the files properly beginning from the 0 version.

Unfortunately i could not find the detailed information on how to reinstall the extension previously installed on my magento 2. Maybe somebody faced the same issue and knows the plan of actions for reinstalling the extension on magento 2 and could help. Your help will be highly appreciated.

EDIT

Example:

  1. I've got module v. 2.0.0 successfully installed with own tables
  2. I've delete the tables manually from the database
  3. I've got module v. 2.0.0 without tabels

How to reinstall tables without completely uninstalling and installing module?

UPDATE:

bin/magento module:uninstall <VendorName>_<ModuleName>
<VendorName>_<ModuleName> is not an installed composer package

where the <VendorName>_<ModuleName> - is the real vendor name and module name of the my module.

bin/magento module:status
List of enabled modules:
Magento_Store
.....
<VendorName>_<ModuleName>
.....
Magento_Weee
Magento_CatalogWidget
Magento_Wishlist
List of disabled modules:
None

UPDATE 2

My extension has the same name attribute value as in <VendorName> and <ModuleName>, in app/code/<VendorName>/<ModuleName>/etc/module.xml as it is indicated further:

<module name="<VendorName>_<ModuleName>" setup_version="1.0.0" />

In addition:

vagrant@magento-dev:/var/www/mgn2$ bin/magento module:disable <VendorName>_<ModuleName>
The following modules have been disabled:
- <VendorName>_<ModuleName>

Cache cleared successfully.
Generated classes cleared successfully. Please re-run Magento compile command
Info: Some modules might require static view files to be cleared. Use the optional --clear-static-content option to clear them.
vagrant@magento-dev:/var/www/mgn2$ bin/magento module:enable <VendorName>_<ModuleName>
The following modules have been enabled:
- <VendorName>_<ModuleName>

To make sure that the enabled modules are properly registered, run 'setup:upgrade'.
Cache cleared successfully.
Generated classes cleared successfully. Please re-run Magento compile command
Info: Some modules might require static view files to be cleared. Use the optional --clear-static-content option to clear them.

This bin/magento setup:upgrade goes without any errors.

UPDATE 2: I’ve found the additional information. Maybe it will be useful for somebody.

mazhalai writes:

module:uninstall is intended to be used, only if you are absolutely certain, that the module wont be used any longer. However, other modules may have dependencies on the module that is to be removed. Hence we use composer remove, which calculates dependencies and removes code of the module from the file system. We cannot uninstall a module that is NOT installed via composer, since there is no way for us to know about dependencies in such a situation. It is risky to remove data and code in such a case. Hence, it is recommended that for modules NOT installed via composer, manual clean up of the database and filesystem is necessary. In module enable/disable, the code is never removed from the filesystem, so that it can be used if required at a later time. Hence, it is not removed from the setup_module table.

Link

PS: I am using the Magento 2.0.4

9
  • What is in name field of module.xml of the module? That should be `<VendorName>_<ModuleName>. Also, how did you install this module initially?
    – Maddy
    Apr 6, 2016 at 14:21
  • @Maddy I’ve updated my question. I’ve written the module from scratch. Apr 6, 2016 at 14:49
  • Thanks for the update, but if you added module manually in app/code as opposed to composer require you cannot uninstall it. That's why the command says <VendorName>_<ModuleName> is not an installed composer package Also, uninstall will only work if the module has uninstall script which implements github.com/magento/magento2/blob/develop/lib/internal/Magento/…
    – Maddy
    Apr 6, 2016 at 14:50
  • ETA: Also, uninstall will only work in the way that you intended(i.e remove tables and data) if the module has uninstall script which implements github.com/magento/magento2/blob/develop/lib/internal/Magento/…
    – Maddy
    Apr 6, 2016 at 15:01
  • @Maddy Thank you for your answer, but how can i reinstall the module (tables) in my case? Apr 6, 2016 at 15:09

4 Answers 4

19

To run your extension again you need to remove your extension entry from setup_module table also remove your table which are created by your extension script then run below command

php bin/magento setup:upgrade

Thanks

1
  • Worked like a charm!!! Apr 26, 2018 at 17:40
3

You can run

php bin/magento module:uninstall module_name

Above code will uninstall your extension. Then run bellow code

php bin/magento setup:upgrade

From your root folder. This will do the update for all extensions

7
  • Thank you for your answer. I’ve tried this way but it doesn’t reinstall the tables from setup extension files (Setup/InstallSchema.php). Apr 6, 2016 at 13:08
  • Did you change the version???
    – Asish Hira
    Apr 6, 2016 at 13:18
  • I am not going to update the extension, i want to reinstall it i.e. install the current version recurrently Apr 6, 2016 at 13:26
  • Then first uninstall it and then again install it
    – Asish Hira
    Apr 6, 2016 at 13:27
  • 1
    Do you have UninstallSchema in your module? devdocs.magento.com/guides/v2.0/install-gde/install/cli/…
    – amitshree
    Apr 6, 2016 at 20:31
1
For a module installed with composer:
# uninstall the module
bin/magento module:uninstall Vendor_ModuleName

# reinstall the module, given that it is still defined in composer.json
composer install
For a custom (non-composer) module installed with Setup/InstallData:
  • Remove the module entry from the setup_module table
  • Run the following command to install it again
bin/magento setup:upgrade
For a custom (non-composer) module installed with Data Patch:
  • Remove the module entry from the patch_list table, look for patch_name like "%Vendor_ModuleName%"
# uninstall the module
bin/magento module:uninstall --non-composer Vendor_ModuleName

# reinstall the module
bin/magento setup:upgrade
0

Please use the following commands serial wise to install the module

1 - php bin/magento setup:upgrade

2 - php bin/magento setup:di:compile

3 - php bin/magento setup:static-content:deploy -f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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