0

I decided to refactor one of my extensions. (because Philwinkle pointed out some "not very well written" code).
In the current version my extension has a db table that holds some values and a model and resource model associated to the table.
In the new version that table becomes obsolete. All the values will be moved to the config section.
I have doubts about how I should approach this. Should I drop the table and the model since so I won't have unnecessary data and code or should I leave them there for some kind of backwards compatibility?
I already have an upgrade script that moves the values from the custom table to the core_config_data table, but there is always the (very slim) chance that someone did some modifications to the extension, and dropping the table and the model might make their version of the extension incompatible after the upgrade?

2

As you already basically said, this comes down to personal preference. I guess the question to ask would be "How much would it hurt a merchant to loose the data in the table?" and "How easy would it be to pull that data from a backup?".

Personally I'd go with a drop table. There already is so much old kipple flying around in Magento, no need to add to it usually.

1
  • I was hoping for such an advice. Like I stated in the question, I already created a migration script, it wasn't easy but I tested with different configurations and it seams to work. If someone added something other columns in the table most probably they will be useless in the next version or they will need to refactor their changes anyway. Thanks.
    – Marius
    Nov 17 '14 at 7:56
2

In doubt, I would create a new major version where you drop the table and clearly state backwards incompatible changes in the release notes. But don't carry around old burdens longer than necessary.

1
  • Yep. It's going to be version 2.0 (currently is 1.2). I guess if magento is allowed to break backwards compatibility on major version changes, I'm allowed also.
    – Marius
    Nov 17 '14 at 7:58
1

I would just drop the model and resource. Ultimately it's about having clean code and as the versions progress it doesn't to my mind make sense to keep classes in there that are doing nothing - particular as you have logic to move the values across anyway. In the end you'll probably even forget why they are there until you look back through your code changes.

It's nice to keep things backwards compatible and also cater for people who may have customised your extension where you can, but having a good, solid, clean release as a platform for building new versions of your 'improved' extension on has a greater priority for me.

1
  • Thanks. I was oping for this. +1 from me. I just accepted Vinai's answer because he was faster.
    – Marius
    Nov 17 '14 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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