Question

How can I create an index on a existing table by using a script file? Any suggestions will be appreciated. Thanks in advanced.

Was it helpful?

Solution

In your Resource Setup create the table with some columns.

$table->addIndex(
  $installer->getIdxName(
    'your_namespace/your_table',
    array(
      'column1',
      'column2',
      'column3',
    ),
    Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
  ),
  array(
    'column1',
    'column2',
    'column3',
  ),
  array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
)
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top