How to Use Setup Scripts for Your Module in Magento

-setupconfigurationinstallationmagento-1sql

I realize, you can use setup scripts for your own module by declaring them in the etc/config.xml file of your module within the <global> space like this:

<resources>
    <catalog_setup>
        <setup>
            <module>Mage_Catalog</module>
            <class>Mage_Catalog_Model_Resource_Setup</class>
        </setup>
    </catalog_setup>
</resources>

Some modules then use the file mysql4-install-0.0.1.php whereas others use install-0.0.1.php.
So when do I use the mysql4 in front of the file name and when do I not use it?

Also, what can I do when my setup script is not running to find out why it is not?

Best Answer

From Magento 1.6 and upwards you don't need to use mysql4 anymore because of added multi-RDBMS support.

To find out why it's not running, you can check the exception.log or system.log, maybe Magento coudn't find your setup class. Creating an install script is pretty straightforward though.

Also check Alan Storm's guide: http://alanstorm.com/magento_setup_resources

Related Topic