setup:upgrade action: adding trigger (mview.xml) to not exist table
Closed this issue · 10 comments
Preconditions (*)
- Magento 2.4.3 - upgrade from 2.2.4 to 2.4.3
- php 7.4
- "amasty/sorting" - upgrade from "^2.6" to "^2.9" version
Steps to reproduce (*)
- run composer update
- run bin/magento setup:upgrade
Expected result (*)
- upgraded Magento and Amaty module to newest version
Actual result (*)
The directory '/app/generated/metadata/' doesn't exist - skipping cleanup
Updating modules:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'amasty_sorting_reviews_link' doesn't exist, query was: CREATE TRIGGER trg_amasty_sorting_reviews_link_after_insert AFTER INSERT ON amasty_sorting_reviews_link FOR EACH ROW
BEGIN
INSERT IGNORE INTOcatalogsearch_fulltext_cl
(entity_id
) VALUES (NEW.product_id
);
END
Description (*)
In vendor/amasty/sorting/etc/mview.xml
<subscriptions>
<table name="amasty_sorting_reviews_link" entity_column="product_id" />
</subscriptions>
</view>
Magento wanted to create trigger trg_amasty_sorting_reviews_link_after_insert
but the table amasty_sorting_reviews_link
wasn't created yet, as you can see in the error .
Table amasty_sorting_reviews_link
is created in the same Amasty module vendor/amasty/sorting/etc/db_schema.xml
.
The problem is in the setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
file in execute
function.
$installer->removeUnusedTriggers();
$installer->installSchema($request);
First, magento removes all triggers and creates new ones in removeUnusedTriggers()
, but the amasty_sorting_reviews_link
table is created in the following installSchema()
function.
Therefore we get an error there as I wrote above.
It might help to change the call position of these functions.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Hi @chochold. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:
- Summary of the issue
- Information on your environment
- Steps to reproduce
- Expected and actual results
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, review the Magento Contributor Assistant documentation.
Add a comment to assign the issue: @magento I am working on this
To learn more about issue processing workflow, refer to the Code Contributions.
- Join Magento Community Engineering Slack and ask your questions in #github channel.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
Hi @engcom-November. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇
-
1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is valid
appears. -
2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Description
label to the issue by yourself. -
3. Add
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to. -
4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-develop
branch, please, add the labelReproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! -
5. Add label
Issue: Confirmed
once verification is complete. -
6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @chochold ,
Amasty is a 3rd party extension and code of this extension is not part of https://github.com/magento/magento2 git repository. We are closing this issue as community is not able to provide fix for it in this repository. All questions, issue reports and fix for them should be addressed to the corresponding extension owners(support) on the Magento Market place page
Thank you.
Hi @engcom-November,
it is no 3rd party module problem. The main problem is in the Magento core setup:upgrade code. Amasty we used as an example.
The problem is in this file
setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
$installer->removeUnusedTriggers();
$installer->installSchema($request);
Because, if you want to create a on xxxxx table
<view id="catalogsearch_fulltext"
class="\Magento\CatalogSearch\Model\Indexer\Mview\Action"
group="indexer">
<subscriptions>
<table name="xxxxx"
entity_column="product_id" />
</subscriptions>
</view>
And xxxxx table is created in the same module where we have mview.xml
, setup:upgrade generates error because the table does not exist when triggers are generated.
Table will generate in the next command
$installer->installSchema($request);
@engcom-November kindly reopen this issue, this is not 3rd party module, while Magento\Framework\Mview\Config\Reader was running to validate before the table was created by schema. In this case mview should ignore or run after the table creation.
Edit
Ignore this, this seems be fixed on #33092