0

Given the scenario:

 an update to a module is deployed and immediately results in breaking the checkout

The expected reaction could be to rollback the deployment. However, with the way magento 2 handles module versioning (if a module's schema or setup version was altered during deployment and setup:upgrade was ran) this would result in an error requiring your module to match version listed in the setup_module table.

The only way I know how to resolve this error would be to either change the module version to match the db version after rolling back the deployment or to manually alter the module version number in the db back to its previous version after the rollback.

I am wondering

  1. Why the magento team decided to have magento throw an error if the module setup or schema version does not match the version in the db?
  2. What is the rollback strategy magento recommends given such a scenario?

...a warning in the logs would seem to be a better option to me rather than throwing a fatal error and forcing downtime.

2 Answers 2

0

You should always pre-build your production site before sending the build to your production server. This will ensure that your items are tested and working and you don't have to run a number of build commands on the production box.

If you do encounter errors, in this case, you should be ready to roll back your code and your database. (This is where having a good UAT plan in place pay off!)

So your basic deployment procedure would be like the following:

Commit to master(Production) branch -> push to build server (maybe staging) -> complete build and test -> tar build and commit to artifact repo for deployment -> deploy to production server(s)

You final deployment will include all items needed to ensure your already build version of Magento will be running in production.

0

You know what. Magento >= 2.3.0 should implement declare a table to new way, and the module version does not save to setup_module table.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Magento_Customer" >
        <sequence>
            <module name="Magento_Eav"/>
            <module name="Magento_Directory"/>
        </sequence>
    </module>
</config>

Remember don't use InstallSchema, InstallData, ...

We should use db_scheme.xml to define the MySQL table, It's will avoid conflict module version if you roll back your system.

Maybe it will help you: https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/db-schema.html

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.