3

Is it appropriate if maintaining the structure of setup resources folder structure as below ?

MyModule > Helper
           sql    > mymodule_customer_setup
                  > mymodule_directory_setup
                  > mymodule_setup

If above structure is fine, then how should I define in the config.xml? I am thinking to define like below:

<resources>
    <mymodule_customer_setup>
        <setup>
            <module>Package_MyModule</module>
        </setup>
    </mymodule_customer_setup>
    <mymodule_directory_setup>
        <setup>
            <module>Package_MyModule</module>
        </setup>
    </mymodule_directory_setup>
    <mymodule_setup>
        <setup>
            <module>Package_MyModule</module>
        </setup>
    </mymodule_setup>
</resources>
6
  • 2
    The best way to find out is to test it and see the results. in my opinion it should work since the config.xml files are merged into one big config.
    – Marius
    Jan 22 '14 at 13:49
  • Marius, you are right, they are working. But after looking at the config.xml, maintaining the script version in sequence might be difficult.
    – Leongelis
    Jan 22 '14 at 14:42
  • Yep. That might be a side effect.
    – Marius
    Jan 22 '14 at 14:44
  • 2
    What is the reason for trying to separate them? If they can be logically separated you could put each into an extension of its own. Jan 25 '14 at 9:06
  • There are reasons you might need multiple for a single module. I have used two in the past in order to have one setup script that works on an external database and one that works on the main database. If the separation is purely because each resource is used by different elements for overloading different core module functionality, I agree it makes sense to have multiple extensions. Jan 25 '14 at 13:58
0

So let's step through what actually happens here.

Install scripts for all.

I created update scripts for all three resources and then in the core_resource table you get the following information.

+--------------------------+---------+--------------+
| code                     | version | data_version |
+--------------------------+---------+--------------+
| mymodule_customer_setup  | 0.7.0   | 0.7.0        |
| mymodule_directory_setup | 0.7.0   | 0.7.0        |
| mymodule_setup           | 0.7.0   | 0.7.0        |
+--------------------------+---------+--------------+

Updates for one script

I then update the version id of the config but include only one update script.

+--------------------------+---------+--------------+
| code                     | version | data_version |
+--------------------------+---------+--------------+
| mymodule_customer_setup  | 0.7.1   | 0.7.1        |
| mymodule_directory_setup | 0.7.1   | 0.7.1        |
| mymodule_setup           | 0.7.1   | 0.7.1        |
+--------------------------+---------+--------------+

So sadly as expected all the resources get updated at the same time even with only the one script :(

Technically there is nothing wrong with this approach, I have tested it and each script does get called but all version numbers get updated at the same time. It might look a bit odd having "missing" scripts in your directories but you could always put empty scripts there that simply start and end setup so as to keep the order.

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.