Skip to content

Instantly share code, notes, and snippets.

@evgv
Created March 17, 2017 07:45
Show Gist options
  • Save evgv/99a14a69dc5391e9f5e58f6fc8ca0d4f to your computer and use it in GitHub Desktop.
Save evgv/99a14a69dc5391e9f5e58f6fc8ca0d4f to your computer and use it in GitHub Desktop.
Magento. Add new column to existed table

Add new column to existed table

/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();

try {
    $installer->getConnection()
        ->addColumn($installer->getTable('blog/blog'), 'thumbnail', array(
            'type'      => Varien_Db_Ddl_Table::TYPE_TEXT,
            'nullable'  => false,
            'length'    => 255,
            'after'     => null, // column name to insert new column after
            'comment'   => 'Title'
        ));   
} catch (Exception $e) {
    Mage::logException($e);
}

$installer->endSetup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment