'Why doesn't my installer SQL run when compiler is disabled?
I have created a scripted SQL installer and in my server when I access MySQL and search, I can't find my new column created with script. My code is:
<?php
$installer = new Mage_Sales_Model_Resource_Setup('core_setup');
//entities for options in table Sales Flat Order Item
$entities = array(
'order_item'
);
//entity for desactivate_count in table Sales Flat Order
$entitydes = array(
'order'
);
//for type text
$optionstxt = array(
'type' => 'text',
'grid' => false
);
//for type int
$optionsint = array(
'type' => 'int',
'grid' => false,
'default' => '0'
);
//just for column incomm_desactivate_count
$optionsdesc = array(
'type' => 'int',
'grid' => true,
'default' => '0'
);
foreach ($entities as $entity) {
$installer->addAttribute($entity, 'incomm_request_active_code', $options);
$installer->addAttribute($entity, 'incomm_cancel', $options);
$installer->addAttribute($entity, 'incomm_exception_count', $optionsint); //value int(2)
$installer->addAttribute($entity, 'incomm_return_active_code', $options);
$installer->addAttribute($entity, 'incomm_activated', $optionsint); //value int(1)
}
foreach ($entitydes as $entity) {
$installer->addAttribute($entity, 'incomm_desactivate_count', $optionsdesc); //value int(2)
}
$installer->endSetup();
I found Magento Module SQL does not run one comment says to compile for execute the installer SQL in my custom module. I need to know why I have to do this... in this link I can't find any more info on that.
Solution 1:[1]
You don't need to compile to run upgrade scripts. In fact, I think you may need to temporarily turn off compilation to run the upgrade scripts (I'm not too sure on this, though).
This depends on the value of the version of your module, which is stored in the core_resource table of your Magento database.
[YOUR MODULE]
config.xml [configuraton-file] - The version number resides in this.
sql (folder) > *.php [upgrade php scripts]
Now, Magento runs the upgrade scripts in your module if (BOTH ARE TRUE):
the version number of your module in config.xml IS GREATER than the version number of your module in "core_resource" module.
the scripts with the new version stated in config.xml file resides in the sql folder of the module. Magento is very peculiar with the filenaming conventions.
I think the version number of your module at core_resource table is already to the latest version so, it's not searching for any upgrade script. So, I suggest you to remove you module's entry or decrease the version number in core_resource table of Magento db. Then maintain files as per Mageto standard and your upgrade script will run.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
