-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
[Tax] add FK to tax/sales_order_tax again #4334
base: main
Are you sure you want to change the base?
Conversation
@sreichel should be easy to merge? Or is it controversial? |
Any idea why was the FK dropped? For stores with large tables, I often experienced MySQL timeout or errors when adding index or modifying tables. Is this update safe? Will it break production? |
The FK there should be minimal, sales_order_tax isn't called that often without Order anyway. |
lgtm. Just dont know why it has been changed. |
It's 13–14 years ago, probably no one remembers that |
Some times you find something in release notes or stackexchange ... but no. |
I am still not sure:
For ref, cursor AI suggest this: // First, clean up orphaned records
$this->getConnection()->query("
DELETE t FROM {$taxTable} t
LEFT JOIN {$orderTable} o ON t.order_id = o.entity_id
WHERE o.entity_id IS NULL
"); |
@kiatng yeah I should probably delete orphaned tax entries |
Use purge option
Description (*)
This Fixes the Missing FK between
sales_order_tax
andsales_flat_order
Right now, when an order gets deleted, the cascade deletes the
sales_flat_order_item
and then the cascade deletes
sales_order_tax_item
,but
sales_order_tax
stays with now the order_id pointing to an order that doesn't exist anymore.That could cause in the wrong taxes to be displayed.
The FK existed before as
FK_SALES_ORDER_TAX_ORDER
, but got removed ages ago.The only other tables that misses the FK are these ones, but they are referenced via creditmemo/invoice/shipment:
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)