Skip to content

migrateDataFromAnotherTable() does not work for declarative schema #34394

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

Closed
5 tasks
DmitryFurs opened this issue Oct 20, 2021 · 29 comments
Closed
5 tasks

migrateDataFromAnotherTable() does not work for declarative schema #34394

DmitryFurs opened this issue Oct 20, 2021 · 29 comments
Assignees
Labels
Area: Framework Component: Bundled Extension Issue is caused by one of the bundled extensions Issue: needs update Additional information is require, waiting for response Issue: On Hold Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@DmitryFurs
Copy link
Contributor

Preconditions

  1. Magneto Community Edition 2.4.3-p1

Steps to reproduce

  1. Create a table using a declarative schema
  2. run setup:upgrade
  3. Add rows to the created table
  4. Rename the table using migrateDataFromAnotherTable() in the declarative schema
  5. run setup:upgrade again

Expected result

  1. Table with a new name has been created
  2. Data from the table with the previous name is copied to the table with the new name

Actual result

  1. Table with a new name has been created
  2. Data is not copied to the new table

Additional Info

During the investigation, it was found that the vertexinc/module-tax module was installed together with Magneto.

This module adds its own trigger to create a table in a declarative schema
image

When you breakpoint in the Magento\Framework\Setup\Declaration\Schema\Operations\CreateTable class, you can see that the trigger added in app/etc/di.xml is missing from the list of added ones, and there is only vertexinc present there
image

After vertexinc was commented out
image

and the setup:upgrade started again, vertexinc disappeared and migrateDataFromAnotherTable appeared
image

After the setup:upgrade was completed, the rows were copied to the new table.

Most likely the reason lies somewhere in the merger app/etc/di.xml and others di.xml files, in our case it is vendor/vertexinc/module-tax/etc/di.xml


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”.
@m2-assistant
Copy link

m2-assistant bot commented Oct 20, 2021

Hi @DmitryFurs. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 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, please 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

@ihor-sviziev ihor-sviziev added the Component: Bundled Extension Issue is caused by one of the bundled extensions label Oct 21, 2021
@ihor-sviziev
Copy link
Contributor

@magento/ext-vertex please take a look at this issue.

@engcom-November engcom-November self-assigned this Oct 21, 2021
@m2-assistant
Copy link

m2-assistant bot commented Oct 21, 2021

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).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: 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 branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced 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.

@jakwinkler
Copy link

jakwinkler commented Oct 22, 2021

This is the exact same issue I've described here
#26433
However, my issue got zero attention for over a year so I've closed it.
Basically adding new arguments to types via di.xml overwrites the entire node.
Hard to say it is desired or a bug, but it is safe to assume the XMLs are merged, as the rest of them (config.xml, cache.xml, routes.xml and so on) are in fact merged.
Imho, it is a bug, but you can see the info about this in devdocs:
https://devdocs.magento.com/guides/v2.4/extension-dev-guide/build/di-xml-file.html

@ihor-sviziev
Copy link
Contributor

@maghamed @kandy, can you explain, why it was implemented in this way? is it a bug, or a feature?

@Den4ik
Copy link
Contributor

Den4ik commented Oct 26, 2021

It was a feature when some one implemented his mind. But currently fix for one bug add two new bugs in different places 🤔

@kandy
Copy link
Contributor

kandy commented Oct 27, 2021

@ihor-sviziev
Array items of DI configuration in the scope of the same area should be merged.
It's a pretty important functionality for modularity and is used in multiple places, For example, \Magento\Framework\Console\CommandListInterface has ~ 30 places in different modules that add items in the common array argument.

I try to reproduce this issue and I do finely after some tries.
So the issue can be reproduced only if DI compilation was not run, and only if the configuration is defined in a prime file (app/etc/env.php)

also please see #3835 (comment)

I prepared draft PR #34457 that probably can fix this issue

@lbajsarowicz
Copy link
Contributor

@kandy Will this also resolve the issue with invalid merging of Product Type configuration?
For example when you want to change the flag refundable for virtual product type in product_types.xml

@kandy
Copy link
Contributor

kandy commented Oct 27, 2021

@lbajsarowicz no, I think it unrelated issues

@m2-community-project m2-community-project bot added the Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. label Oct 28, 2021
@sidolov sidolov added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Oct 28, 2021
@ilnytskyi
Copy link
Contributor

ilnytskyi commented Nov 4, 2021

Faced similar issue in DI when wanted to add new items in different area
#34464

@DmitryFurs
Copy link
Contributor Author

Is there any news here? Thanks!

@engcom-November engcom-November removed their assignment Aug 8, 2022
@engcom-November engcom-November added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Sep 5, 2022
@engcom-Delta engcom-Delta self-assigned this Sep 19, 2022
@m2-assistant
Copy link

m2-assistant bot commented Sep 19, 2022

Hi @engcom-Delta. 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).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: 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 branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced 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.

@github-jira-sync-bot github-jira-sync-bot added Progress: ready for grooming Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: ready for grooming labels Nov 16, 2022
@engcom-Hotel
Copy link
Contributor

Hello @DmitryFurs @navarr,

We have discussed this issue with developers internally and come to the below conclusion:

As per the analysis for the issue, the vertexinc/vertex-tax-module:4.2.8 di.xml is an area-specific configuration, and the app/etc/di.xml is the initial one. As per devdocs the area-specific config will override the initial one so this is expected behavior. we can check further Here.

We have one different example as well to demonstrate the expected behavior of DI.
vendor/magento/module-customer/etc/di.xml
image

app/etc/di.xml
image
image

The module-specific configuration will override the same expected behavior.

Thanks

@engcom-Hotel engcom-Hotel removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Nov 24, 2022
@m2-community-project m2-community-project bot added Progress: ready for dev and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Nov 24, 2022
@engcom-Hotel engcom-Hotel self-assigned this Nov 24, 2022
@navarr
Copy link
Member

navarr commented Nov 24, 2022

@engcom-Hotel I think everyone in this thread understands that's the expected behavior of XML merge as it exists today

However, I think the point of the ticket is that database triggers especially should not be disappear if a module tries to add one

This has two potential solutions to that regard:

  • Merge initial and area configuration instead of overwriting
  • Or Magento needs to host important configuration in an area configuration file

Personally, I've never understood why app/etc/di.xml exists or is treated differently.

@DmitryFurs
Copy link
Contributor Author

@engcom-Hotel I completely agree with @navarr

@engcom-Hotel
Copy link
Contributor

Hello @navarr @DmitryFurs,

We are under discussion on this issue internally. Will keep you posted on this soon.

Thanks

@engcom-Hotel
Copy link
Contributor

Moving this ticket "On hold"

@ihor-sviziev
Copy link
Contributor

@engcom-Hotel @engcom-Echo any updates? Why task was closed w/o any comments?

@engcom-Bravo
Copy link
Contributor

Hi @ihor-sviziev @DmitryFurs,

As per the Internal team they are not able to reproduce the issue hence they have closed jira form their side.

Thanks.

@navarr
Copy link
Member

navarr commented Sep 28, 2023

Were there any changes made to the way di.xml entries are loaded, or did internal just give up on fixing this architectural issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: Bundled Extension Issue is caused by one of the bundled extensions Issue: needs update Additional information is require, waiting for response Issue: On Hold Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Development

Successfully merging a pull request may close this issue.