-
Notifications
You must be signed in to change notification settings - Fork 170
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
[4.x]: Invalid ownerId in addresses table after upgrade from 3.x #2939
Comments
Database dump sent to support@craftcms.com |
I've also got a large number of addresses with a |
FTR addresses with a null value in the |
Having tried this a few more times over the last couple of weeks I'm still having the same problem. A key point I think: The main thrust of this issue is is not There is a separate issue to do with a first party commerce plugin that is currently preventing me seeing if a garbage collection run will mitigate or fix any of this but I plan to have another go at that this week. |
@rob-baker-ar Does the migration issue resolved when Digital Products is disabled before upgrade? |
@pdaleramirez With Digital Products disabled, I still get the integrity constraint exception from craftcms/digital-products#75 when trying to run garbage collection before the upgrade (so as an effect the upgrade still runs with ~1.6million customer records). For the upgrade itself, after doing:
I am still left with the headline issue (numeric |
@rob-baker-ar This issue has been fixed on craftcms/digital-products version 3.1.0. Please open an issue on the craftcms/digital-products if you are still experiencing the issue |
Perhaps I'm missing something: how would the fix to digital products affect rows on the address table that are effectively detached from the elements table? There are foreign key constraints on the Looking at this from v3.1.0: craftcms/digital-products@3414823 |
Addresses tables shouldn't be associated with digital product element as owner. Unless it explicitly assigned through custom module or plugin in that case a custom query should be executed to delete the association. |
I couldn't agree more. We have no code that changes However, if it is safe to do a delete on the |
@rob-baker-ar Deleting the row should be fine if the foreign key doesn’t exist. |
What happened?
Starting versions:
Craft:
Craft Pro 3.7.51
Commerce:
3.4.16
Description
After the steps described in "Steps to reproduce", running this query directly on the database:
This might be a clue to an issue when running a similar query from a PHP / Craft context:
Exception thrown is:
Steps to reproduce
composer.json
composer upgrade
craft clear-caches/all
craft cache/purge-all
craft migrate/all
craft commerce/upgrade
In the last step, all defaults were selected, it's output:
All the above steps complete successfully - I have their output if needed.
Row counts
commerce_customers
count (beforecommerce/upgrade
): 1643564commerce_addresses
count (beforecommerce/upgrade
): 2765commerce_customers
count (aftercommerce/upgrade
): 1161addresses
count (aftercommerce/upgrade
): 2767As part of the upgrade the number of rows is massively reduced - generally speaking this is probably good - I don't need 1.6m rows in
commerce_customers
as the huge majority are the result of old carts for customers that never completed an order.Expected behavior
All rows in
addresses
table have a valid value forownerId
.Actual behavior
Something is going wrong during
commerce/upgrade
command leaving broken data in the addresses table - there are both rows with anull
value forownerId
as well as rows that have a integerownerId
that no longer point to it's owner (see the value show in in the exception message).Craft CMS version
4.2.1.1
Craft Commerce version
4.1.0
PHP version
8.1.2
Operating system and version
Ubuntu 22.04 (Linux 5.15.0-46-generic)
Database type and version
MySQL 5.5.5 (mariadb Ver 15.1 Distrib 10.6.7-MariaDB)
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: