1

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>
3
  • can you post your code? Commented Mar 10, 2016 at 9:46
  • Module.xml :::: <config xmlns:xsi="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> Commented Mar 10, 2016 at 9:48
  • the above is my code Commented Mar 10, 2016 at 9:51

1 Answer 1

0

$setup->startSetup() and $setup->endSetup() should be outside if clause.

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)
    {

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

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

        }
        $setup->endSetup();
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.