sales_flat_order
is the full name of the table
and so you have to use alias in $installer->getTable()
In $installer->getTable()
parameter like module_alias/table_alias.
In that case try with
$installer->getTable('sales/order')
When you write this it will return table name sales_flat_order
because
module_alias = sales
table_alias = order
EDIT
You can use below script to add new column. It works fine in my system
$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();
I am using Varien_Db_Ddl_Table::TYPE_TEXT
insted of Varien_Db_Ddl_Table::TYPE_VARCHAR
because TYPE_VARCHAR
is deprecated
You can check @ Varien_Db_Adapter_Pdo_Mysql::$_ddlColumnTypes
And If you specify type TYPE_TEXT
but set length to lets say 255
Magento will create a MySQL
column of VARCHAR
type.
Best Answer
You need to use below cod in your setup script of your custom module