magento2
magento2 copied to clipboard
How can i create a custom Database Trigger when install/upgrade module
Summary
In my case, I want to create a custom Database trigger, that is quite complex to handle BEFORE UPDATE on a table.
For database tables, I can use the db_schema.xml file as well, but I don't know how to achieve the DB trigger.
I have tried to create a DataPatch file in Setup\Patch\Data and implement DataPatchInterface with raw SQL query to create a trigger. However, it got an error DB schema cannot be in a transaction, seems all of the migration codes are wrapped by transaction from Magento.
Examples
Nope
Proposed solution
No response
Release note
No response
Triage and priority
- [ ] 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 @ngoctai-nfq. Thank you for your report. To speed up processing of this issue, 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. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: 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.
Hello @ngoctai-nfq,
This is a forum to post issues or bugs related to core magento. You can raise queries as such on magento stackexchange. Hence closing this issue.
Thank you.