Created
January 20, 2014 22:40
-
-
Save xcommerce-gists/8530793 to your computer and use it in GitHub Desktop.
Sample Magento module database installation script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* News installation script | |
* | |
* @author Magento | |
*/ | |
/** | |
* @var $installer Mage_Core_Model_Resource_Setup | |
*/ | |
$installer = $this; | |
/** | |
* Creating table magentostudy_news | |
*/ | |
$table = $installer->getConnection() | |
->newTable($installer->getTable('magentostudy_news/news')) | |
->addColumn('news_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( | |
'unsigned' => true, | |
'identity' => true, | |
'nullable' => false, | |
'primary' => true, | |
), 'Entity id') | |
->addColumn('title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( | |
'nullable' => true, | |
), 'Title') | |
->addColumn('author', Varien_Db_Ddl_Table::TYPE_TEXT, 63, array( | |
'nullable' => true, | |
'default' => null, | |
), 'Author') | |
->addColumn('content', Varien_Db_Ddl_Table::TYPE_TEXT, '2M', array( | |
'nullable' => true, | |
'default' => null, | |
), 'Content') | |
->addColumn('image', Varien_Db_Ddl_Table::TYPE_TEXT, null, array( | |
'nullable' => true, | |
'default' => null, | |
), 'News image media path') | |
->addColumn('published_at', Varien_Db_Ddl_Table::TYPE_DATE, null, array( | |
'nullable' => true, | |
'default' => null, | |
), 'World publish date') | |
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( | |
'nullable' => true, | |
'default' => null, | |
), 'Creation Time') | |
->addIndex($installer->getIdxName( | |
$installer->getTable('magentostudy_news/news'), | |
array('published_at'), | |
Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX | |
), | |
array('published_at'), | |
array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX) | |
) | |
->setComment('News item'); | |
$installer->getConnection()->createTable($table); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment