Having Multiple Setup Resources Under SQL Folder
-
16-10-2019 - |
سؤال
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>
المحلول
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.