1

How can I add a new column to existing Magento core table via install script? (without using pure SQL)

$installer = $this;
$installer->startSetup();

$installer->getConnection()
->addColumn($installer->getTable('sales/order'),'custom_value', array(
    'type'      => Varien_Db_Ddl_Table::TYPE_TEXT,
    'nullable'  => false,
    'length'    => 255,
    'after'     => null, // column name to insert new column after
    'comment'   => 'Title'
    ));   
$installer->endSetup();

and also I am updating version as per upgrade version I have created mysql4-upgrade-0.1.0-0.1.1 in sql folder and added above code. and change version in config.xml and cleared caches too, but its not working.

2

2 Answers 2

2

Please use :

$installer = $this;
$installer->startSetup();

$installer->getConnection()
->addColumn($installer->getTable('sales/order'),'custom_value', array(
    'type'      => Varien_Db_Ddl_Table::TYPE_TEXT,
    'nullable'  => false,
    'length'    => 255,
    'after'     => null, // column name to insert new column after
    'comment'   => 'Title'
    ));   
$installer->endSetup();
0
0

Try this:

might help you.

$installer = $this;

$installer -> startSetup();
$installer->getConnection()->addColumn($installer->getTable('sales/order'),'custom_value', "varchar(255)  NOT NULL default '0'");


$installer -> endSetup();
1
  • i have used this ..still did not change Commented Nov 19, 2016 at 4:17

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