-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a custom EAV entity type can cause mysql integrity constraint violations when reinitializing the database #10398
Comments
@hostep, thank you for your report. |
Hi @engcom-Charlie. Thank you for working on this issue.
|
Hello @hostep We are not able to reproduce this issue on the latest 2.4-develop branch by provided steps. We are closing this issue due to branch
|
This was most likely fixed as a side-effect of #21020 or #21423 where the sort order of modules has been changed so that Magento modules are now always loaded first and all the rest later. It wouldn't surprise me if that change will get reverted on day or another because it doesn't feel right in my opinion. If that happens one day, then this issue will start happening again. |
Preconditions
Steps to reproduce
bin/magento setup:install
with the--cleanup-database
flagExpected result
Actual result
Discussion
This problem happens because certain Magento modules (Magento_Customer, Magento_Catalog & Magento_Sales) use a hardcoded entity_type_id in their database installation scripts.
In this case, the custom module gets installed before the Magento_Sales module and adds an eav entity type with id '5'. The Magento_Sales module then tries to install itself, but fails to do, because it wants to use id '5' as well, but this one is already taken by the custom module.
We can fix it by adding 'Magento_Sales' in the sequence of our custom module, but this doesn't make much sense to me, since the custom module is not depending on the 'Magento_Sales' module for any functionality.
Is this considered a bug, or should something like this be better documented?
I'm wondering why the Magento_Customer and Magento_Catalog module's setups are being executed before our custom module though, if somehow Magento_Sales could also be "automagically" be executed before a custom module who wants to create an Entity Type that would fix the bug, but this is probably not so easy?
Example module files
app/code/A/B/registration.php
:app/code/A/B/etc/module.xml
:app/code/A/B/Model/ResourceModel/Example.php
:app/code/A/B/Setup/ExampleSetup.php
:app/code/A/B/Setup/InstallData.php
:The text was updated successfully, but these errors were encountered: