8

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

16

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)
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.