1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Magento 2 module “data_version - not upgrading"?

Discussion in 'Programming/Internet' started by Pawankumar, Oct 8, 2018.

  1. Pawankumar

    Pawankumar Guest

    In Magento 2.0 I have written UpgradeData and UpgradeSchema and I have changed the setup_version in module.xml. After that I run php bin/magento setup:upgrade After this in the database, schema_version is upgrading but data_version not upgrading. Any Ideas?

    UpgradeData.php

    namespace Vendor\Pawan\Setup;
    use Magento\Framework\Setup\UpgradeDataInterface;
    use Magento\Framework\Setup\ModuleContextInterface;
    use Magento\Framework\Setup\ModuleDataSetupInterface;

    /**
    * Upgrade data for SImple Google Shopping
    */
    class UpgradeData implements UpgradeDataInterface
    {

    /**
    * @param ModuleDataSetupInterface $setup
    * @param ModuleContextInterface $context
    */
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {

    // $context->getVersion() = version du module actuelle
    // 10.0.0 = version en cours d'installation

    if (version_compare($context->getVersion(), '10.0.0') < 0) {
    $installer = $setup;
    $installer->startSetup();
    // do what you have to do

    $installer->endSetup();
    }
    }
    }


    Module.xml

    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Vendor_Pawan" setup_version="2.1.1">

    </module>
    </config>

    Login To add answer/comment
     

Share This Page