Skip to content

Instantly share code, notes, and snippets.

@herveguetin
Created July 22, 2014 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herveguetin/903cdc6cdfaafaa3fcf6 to your computer and use it in GitHub Desktop.
Save herveguetin/903cdc6cdfaafaa3fcf6 to your computer and use it in GitHub Desktop.
The right way to add a column to an existing table in Magento.
<?php
$installer = $this->startSetup();
$installer->getConnection()
->addColumn(
$installer->getTable('module/table_alias'),
'sql_column_name',
array(
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, // Or any other type from Varien_Db_Ddl_Table
'nullable' => true, // Or false...
'default' => null, // Or any default value
'comment' => 'Column Comment'
)
);
$installer->endSetup();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment