Create database tables in setup scripts

The following snippet shows, how to create database tables in a setup script. It uses no direct queries against the database but the an object oriented way Magento does such things. (This snipped assumes  that your resource setup model is derived from Mage_Core_Model_Resource_Setup)

As you can see, it is also possible to add indexes and foreignkeys by using a Varien_Db_Ddl_Table instance.

Here are the database related parts of the config.xml:

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.