Magento 2 Developement

Magento 2 : When exactly to use php bin/magento setup:upgrade

If you enabled one or more modules, then you will need to run magento setup:upgrade to update the database schema.

First line simply adds your module to the app/etc/config.php. Please note that your magento will crash until you run second command.

Second line trigger setup scripts of all Magento modules that needs setup. Current module version is saved in setup_module table ( remember core_resource in Magento 1 ).

By default, magento setup:upgrade clears compiled code and the cache. Typically, you use magento setup:upgrade to update components and each component can require different compiled classes.

The optional –keep-generated option prevents generated code from being deleted. It should be used only in limited circumstances by experienced system integrators. –keep-generated should never be used in a development environment. Improper use of this optional parameter can cause errors during code execution.

Useful Links:
Magento 2 Command-Line Interface (CLI) Commands List
Enable or disable modules

Leave a Reply

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