Setup scripts are versioned. It is known. As a result, any time you use a reference from an external object or class, you run the risk of the setup script itself changing ex post facto. For example, suppose I want to insert a new status that is the default for the "New" state:

$tbl = $installer->getTable('sales/order_status_state');
$fields = array('status', 'state', 'is_default');
$values = array(
    'is_default' => 1,
$conn->insertArray($tbl, $fields, array(array_combine($fields, $values)));

Maybe it's unlikely that a future release of Magento would change the value of Mage_Sales_Model_Order::STATE_NEW, but it could happen, and if it did, this setup script would have the same version number(s), but produce different results. That's bad!

The real question here is that good programming practice tells me that I shouldn't have the string 'unsubmitted' in my code/config more than once. I would really like to put it in config.xml, actually, but I can't, because if I do that then future versions of this setup script can change meaning without actually changing the code of the setup script.

Has anyone found a reasonable compromise between hard-coding values into setup scripts and maintaining pure differences between versions?

1 Answer 1


I think this is rather a non issue, something like Mage_Sales_Model_Order::STATE_NEW is never going to change to something which is completely unrelated to what it was before. It will very likely never change at all but if it did it will just change to the next incantation representing the same thing. If you are concerned about that, then you need to be concerned about it not only in setup scripts, but any class and method you write, or indeed any core class or method!

  • What about the 'unsubmitted' string and the best practice of not hard-coding values?
    – kojiro
    Aug 5, 2014 at 14:09
  • If that is a string you have defined for a module you are going to maintain then it's up to you how you maintain that. Aug 5, 2014 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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