Magento – Module Upgrade Script Not Running

attributescategorysetup-script

I would like to do something as simple as create an upgrade script for an existing module to add custom category attributes. Unfortunately this has been anything but simple as no upgrade script is ever run. I've read about a dozen tutorials and stackoverflow questions to find an answer to no avail.

Below is my config.xml with version 0.2.1 at the top:

   <resources>
        <mymodule_services_setup>
            <setup>
                <module>MyModule_Services</module>
                <class>MyModule_Services_Model_Resource_Eav_Mysql4_Setup</class>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </mymodule_services_setup>
        <mymodule_services_write>
            <connection>
                <use>core_write</use>
            </connection>
        </mymodule_services_write>
        <mymodule_services_read>
            <connection>
                <use>core_read</use>
            </connection>
        </mymodule_services_read>
    </resources>

The install script at MyModule/Services/sql/mymodule_services_setup/mysql4-upgrade-0.2.1.php:

  $installer = $this;
  //$installer->installEntities();
  Mage::log('running script', null, 'services_upgrade.log');

  $installer->startSetup();

  $installer->addAttribute('catalog_category', 'hide_page_title',  array(
    'type'     => 'int',
    'label'    => 'Hide Page Title',
    'input'    => 'select',
    'source'   => 'eav/entity_attribute_source_boolean',
    'global'   => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'required' => false,
    'default'  => 0
  ));

  Mage::log('in the middle', null, 'services_upgrade.log');

  $installer->addAttribute('catalog_category', 'show_percentage_off',  array(
    'type'     => 'int',
    'label'    => 'Show Percentage Off',
    'input'    => 'select',
    'source'   => 'eav/entity_attribute_source_boolean',
    'global'   => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'required' => false,
    'default'  => 0
  ));

  Mage::log('finished', null, 'services_upgrade.log');
  $installer->endSetup();

The Setup class (MyModule/Services/Model/Resource/Eav/Mysql/Setup.php) specified in the config.xml is there but empty as follows for now:

class MyModule_Services_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
{

}

Resource_core shows the module version being bumped up but the upgrade script is never run.

If anyone can give any help I would be eternally grateful as this simple task is taking hours.

Best Answer

i think you must enter:

MyModule/Services/sql/mymodule_services_setup/mysql4-upgrade-0.2.0-0.2.1.php:

to upgrade from 0.2.0 to 0.2.1 and then type 0.2.1 into config.xml <version> tag.