magento2
magento2 copied to clipboard
#36336 Prefix all Indexes and Constraints
Description (*)
Pull Request enforces Magento to prefix MySQL object names, not only hash. This change answers a need of having multiple objects inside of a single Table (e.g. Constraint and Index).
The change also simplifies the trimHash method to use hashes in a way known for Git commit hash (use the first 8 letters), instead of a method that... returns empty string.
Additionally, added the test coverage for "Just a hash" return.
Related Pull Requests
N/A
Fixed Issues (if relevant)
- Fixes magento/magento2#36336
Manual testing scenarios (*)
- Create two objects inside of the same table (
db_schema.xml)
<table name="quote_item">
<constraint xsi:type="unique" referenceId="ThisDoesNotMatter">
<column name="quote_item_id"/>
</constraint>
<index referenceId="ThisDoesNotMatterToo" indexType="btree">
<column name="quote_item_id"/>
</index>
</table>
- Execute
bin/magento setup:upgrade
Current Behavior
SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'XXX_QUOTE_ITEM_QUOTE_ITEM_ID', query was: ALTER TABLE `xxx_quote_item` ADD INDEX `XXX_QUOTE_ITEM_QUOTE_ITEM_ID` (`quote_item_id`)
Expected Behavior
Execution setup:upgrade should pass correctly.
Questions or comments
Contribution checklist (*)
- [ ] Pull request has a meaningful description of its purpose
- [ ] All commits are accompanied by meaningful commit messages
- [ ] All new or changed code is covered with unit/integration tests (if applicable)
- [ ] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
- [ ] All automated tests passed successfully (all builds are green)
Hi @lbajsarowicz. Thank you for your contribution! Here are some useful tips on how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:
@magento give me test instance- deploy test instance based on PR changes@magento give me 2.4-develop instance- deploy vanilla Magento instance
:exclamation: Automated tests can be triggered manually with an appropriate comment:
@magento run all tests- run or re-run all required tests against the PR changes@magento run <test-build(s)>- run or re-run specific test build(s) For example:@magento run Unit Tests
<test-build(s)> is a comma-separated list of build names.
Allowed build names are:
Database CompareFunctional Tests CEFunctional Tests EEFunctional Tests B2BIntegration TestsMagento Health IndexSample Data Tests CESample Data Tests EESample Data Tests B2BStatic TestsUnit TestsWebAPI TestsSemantic Version Checker
You can find more information about the builds here :information_source: Run only required test builds during development. Run all test builds before sending your pull request for review.
For more details, review the Code Contributions documentation. Join Magento Community Engineering Slack and ask your questions in #github channel.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.
@magento run Unit Tests
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.
@magento run all tests
By the way, I tried to run Unit Tests locally, but... ~5% of them fail with whitespace mismatch:
13) Magento\Framework\Stdlib\Test\Unit\DateTime\DateTimeFormatterTest::testFormatObjectNumericFormat with data set #4 (1, 'March 30, 2022 at 12:01:02 AM...n Time')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'March 30, 2022 at 12:01:02 AM Greenwich Mean Time'
+'March 30, 2022 at 12:01:02 AM Greenwich Mean Time'
/var/www/html/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeFormatterTest.php:165
14) Magento\Framework\Stdlib\Test\Unit\DateTime\DateTimeFormatterTest::testFormatObjectNumericFormat with data set #5 (0, 'Wednesday, March 30, 2022 at ...n Time')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Wednesday, March 30, 2022 at 12:01:02 AM Greenwich Mean Time'
+'Wednesday, March 30, 2022 at 12:01:02 AM Greenwich Mean Time'
/var/www/html/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeFormatterTest.php:165
15) Magento\Framework\Stdlib\Test\Unit\DateTime\TimezoneTest::testGetDatetimeFormat with data set #0 ('en_US', 3, 'M/d/yy h:mm a')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'M/d/yy h:mm a'
+'M/d/yy h:mm a'
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.
@magento run all tests
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.
@magento run all tests
@magento run all tests
Hello @lbajsarowicz,
Thanks for the contribution!
I'm getting an open search error with your PR code. When I revert it, it works as expected. Could you please check it?
To reproduce the issue, run the bin/magento set:up command.
Please see the screenshot below.
Addressing your feedback @engcom-Hotel
@magento run all tests
As discussed with @lbajsarowicz over Slack, he mentioned that he will address this comment.
Closing this PR since it has not been updated for a period of 14 days. Please feel free to reopen it if needed.
C'mon. People have work here, enough billable work to queue non-billable Test Coverage for later. 😠
Hello @lbajsarowicz,
Thank you for your contributions.
I am reopening this PR. Please address this comment, as it is blocking us from proceeding further: #37975 (comment).
Thanks!
Hi @lbajsarowicz. Thank you for your contribution! Here are some useful tips on how you can test your changes using Magento test environment. :exclamation: Automated tests can be triggered manually with an appropriate comment:
@magento run all tests- run or re-run all required tests against the PR changes@magento run <test-build(s)>- run or re-run specific test build(s) For example:@magento run Unit Tests
<test-build(s)> is a comma-separated list of build names.
Allowed build names are:
Database CompareFunctional Tests CEFunctional Tests EEFunctional Tests B2BIntegration TestsMagento Health IndexSample Data Tests CESample Data Tests EESample Data Tests B2BStatic TestsUnit TestsWebAPI TestsSemantic Version Checker
You can find more information about the builds here :information_source: Run only required test builds during development. Run all test builds before sending your pull request for review.
For more details, review the Code Contributions documentation. Join Magento Community Engineering Slack and ask your questions in #github channel.
Hello @lbajsarowicz,
Thank you for your contributions!
We are putting this PR on hold for now. Once the issue referenced in https://github.com/magento/magento2/pull/37975#issuecomment-2373370709 has been resolved, we’ll proceed with the next steps.
Thank you for your understanding!
Hi @lbajsarowicz,
This is a reminder to please address this https://github.com/magento/magento2/pull/37975#issuecomment-2373370709 so that we can proceed further with this.
Thank you!
Update Working on it.
@magento run all tests
@engcom-Dash Fixed. The root cause was unexpected prefix added to Table Names in \Magento\Framework\DB\Adapter\Pdo\Mysql::getTableName.
@magento run all tests
@magneto run all tests
Update
- Database Compare are false negatives (we do change structure in this PR)
- Functional Tests B2B - clear false negative,
- Regenerated DB Whitelists.
@magento run all tests
@engcom-Dash Fixed. The root cause was unexpected prefix added to Table Names in
\Magento\Framework\DB\Adapter\Pdo\Mysql::getTableName.@magento run all tests
Thanks @lbajsarowicz, for the updates.
Moving it to "Pending Review" as new files are being added to the PR.
There is one more issue with the Integration Tests. The DB whitelists would fail for non-CommunityEdition tables, as these need to be regenerated after my changes (their indexes and constraints would have the prefix)
Hello @lbajsarowicz,
Since its related issue has been marked as a Feature Request, we need a PO approval to move forward for this. Please allow us some time for the same.
Till then we are moving this PR On Hold.
Thanks for the contribution.
Hello @lbajsarowicz,
We have received a response from the PO, indicating that renaming database table columns, indexes, or constraints is considered a breaking change. This could disrupt extensions and custom scripts that reference the original names. To adopt such changes, customers would need to implement database migration scripts to maintain data integrity and consistency, which carries a risk of data loss.
Given these implications, I believe it would be best not to proceed with this PR.
However, we sincerely appreciate your valuable contributions.
Thanks