How can I add a new column to existing Magento core table via install script? (without using pure SQL)
I want to use the Magento way which is using alias methods to create install script.
So far I followed few tutorials. But seems to be not working properly. This StackOverflow ALTER TABLE in Magento setup script without using SQL answer was somewhat similar to my question. But what is the content should be put into module's confg.xml
file? Do I need to just define resource model, model and setup data would be enough?
The relevant portion of the config.xml
(of my module) is as follow.
<config>
. . .
<global>
<models>
<mymodule>
<class>Mynamespace_Mymodule_Model</class>
<resourceModel>mymodule_resource</resourceModel>
</mymodule>
<mymodule_resource>
<class>Mynamespace_Mymodule_Model_Resource</class>
</mymodule_resource>
</models>
<resources>
<mymodule_setup>
<setup>
<module>Mynamespace_Mymodule</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</mymodule_setup>
<mymodule_read>
<connection>
<use>core_read</use>
</connection>
</mymodule_read>
<mymodule_write>
<connection>
<use>core_write</use>
</connection>
</mymodule_write>
</resources>
. . . .
</config>
And my install script is as follows.
$installer = $this;
$installer->startSetup();
$installer->getConnection()
->addColumn($installer->getTable('sales_flat_order'),'custom_value', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
'nullable' => false,
), 'Title');
$installer->endSetup();
But I'm getting the following error.
SQLSTATE[42S02]: Base table or view not found: 1146 Table '255.sales_flat_order' doesn't exist
Any suggestion to fix this would be appreciated.
255
?