How to create a UNIQUE column in magento install script

You can add unique columns in your install script easier than you thought. After searching for a while in search engines without any results, the good old method helped: search in all files of magento… The good news is that you get the results of my searches right here:

$installer = $this;
$table = $installer->getConnection()


->addIndex($installer->getIdxName(SOME_TABLE_NAME_DEFINITION, array(‘my_unique_column_name’), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), “my_unique_column_name”,array(“type” => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE));


Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload the CAPTCHA.