Reputation: 25122
I'm trying to add a new field to the sales_flat_order table via a module I'm making. I've tried to run the setup script but it doesn't seem to be changing the table at all.
Here is the update script:
mysql4-upgrade-0.1.1-0.1.2.php
<?php
$installer = $this;
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'expected_delivery_date', 'datetime');
Here is my config.xml
...
<modules>
<Optimiseweb_OrderPad>
<version>0.1.2</version>
</Optimiseweb_OrderPad>
</modules>
...
<resources>
<orderpad>
<setup>
<module>Optimiseweb_Orderpad</module>
<class>Optimiseweb_Orderpad_Model_Mysql4_Setup</class>
</setup>
</orderpad>
</resources>
<models>
<orderpad>
<class>Mage_Sales_Model</class>
<resourceModel>orderpad_mysql4</resourceModel>
</orderpad>
<orderpad_mysql4>
<class>Optimiseweb_Orderpad_Model_Mysql4</class>
<entities>
<order><table>sales_flat_order</table></order>
</entities>
</orderpad_mysql4>
</models>
...
The two models referred to in the config.xml
Optimiseweb/Orderpad/Model/Mysql4.php
<?php
class Optimiseweb_Orderpad_Model_Mysql4 extends Mage_Core_Model_Abstract
{
}
Optimiseweb/Orderpad/Model/Mysql4/Setup.php
<?php
class Optimiseweb_Orderpad_Model_Mysql4_Setup extends Mage_Sales_Model_Resource_Setup
{
}
Anyhelp to add the new field to the orders table would be most appreciated.
Upvotes: 0
Views: 1864
Reputation: 2233
If you need to add a column to a flat sales table, it is better to do via adding an attribute to a sales entity (sales_order). Make sure that your install modell Optimiseweb_Orderpad_Model_Mysql4_Setup
extends Mage_Sales_Model_Resource_Setup
and execute
$installer = $this;
$installer->startSetup();
$installer->addAttribute('order', 'expected_delivery_date', array('type'=>'datetime'));
$installer->endSetup();
Upvotes: 2