I have a flat table that I would like to add a column to, and upload an image file in the admin. How would I achieve this via installer/upgrade script?

Also as a side note, does it make more sense to create a separate table for this?

  • Tell us more about the flat table you are trying to add the image to and for which functionality? – Paras Sood Dec 14 '14 at 16:52
  • We got a module that doesn't use an eav resource model. So in essence, it is an entity that uses a flat resource model and we want to add an attribute of type image, so we can upload it and then render it on the frontend along with the rest of the entry. – DWils Dec 14 '14 at 21:32

Write something like this in your upgrade script:

$installer = $this;
/* @var $installer Mage_Core_Model_Resource_Setup */


$conn = $installer->getConnection();
$table = $installer->getTable('orderexporter/exportorders');
$conn->addColumn($table, 'exported_at', 'datetime');


Here orderexporter/exportorders is the factory string for my model, you would need to write one for yours. I am adding field exported_at of type date time. You could add fields of others types like text, int etc.

| improve this answer | |

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