cancel
Showing results for 
Search instead for 
Did you mean: 

Integrity constraint violation while upgrading 2.1.16 to 2.3.3

Integrity constraint violation while upgrading 2.1.16 to 2.3.3

I've been working to get an old Magento site from 2.1.16 to 2.3.3 for a while, hope someone can help.

 

This site was migrated from Magento 1 by a previous admin that is gone, so not sure how they have upgraded in the past.

 

I first tried composer without luck so went with "method 3".

 

Created a working copy of the site in test subdomain and uploaded the 2.3.3 files overwriting the existing.

 

Switched test subdomain to PHP 7.2 to be compatible with Magento 2.3.3

 

Ran php72 bin/magento setup:upgrade and first got some "has been already defined in" errors but got past by deleting the extra /app/code/Magento/ folders that already had /vendor folders.

 

Eventually the upgrade seemed to start working but then stopped with:

 

loginid@m03 [~/test]# php72 bin/magento setup:upgrade
Cache cleared successfully
File system cleanup:
/home/loginid/test/generated/code/Composer
/home/loginid/test/generated/code/Dotdigitalgroup
/home/loginid/test/generated/code/MSP
/home/loginid/test/generated/code/Magento
/home/loginid/test/generated/code/Symfony
/home/loginid/test/generated/code/Yotpo
The directory '/home/loginid/test/generated/metadata/' doesn't exist - skipping cleanup
Updating modules:
Schema creation/updates:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3-' for key 'AST_EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_CODE', query was: ALTER TABLE `ast_eav_attribute_group` ADD CONSTRAINT `AST_EAV_ATTR_GROUP_ATTR_SET_ID_AST_EAV_ATTR_SET_ATTR_SET_ID` FOREIGN KEY (`attribute_set_id`) REFERENCES `ast_eav_attribute_set` (`attribute_set_id`) ON DELETE CASCADE, ADD CONSTRAINT `AST_EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_CODE` UNIQUE KEY (`attribute_set_id`,`attribute_group_code`)
loginid@m03 [~/test]#

 Could anyone help? This install seems kind of a mess although the current site works, just can't add any modules because of the old version.

 

Would it be possible to start from a fresh install of Magento 2.3.3 and import all the products and pages to get rid of all the legacy code and database entries?

3 REPLIES 3

Re: Integrity constraint violation while upgrading 2.1.16 to 2.3.3

Hi @damon18,

You should upgrade in the below sequence.

 

    1. Upgrade the magento 2.1.6 to 2.1.18 ( Stable/Latest version of magento 2.1 release).
    2. Then upgrade 2.1.18 to 2.2.8 ( Stable/Latest version of magento 2.2 release).
    3. After that upgrade the magento 2.2.8 to 2.3.3 ( Stable/Latest version of magento 2.3 release).

 
I hope it will help you!

Re: Integrity constraint violation while upgrading 2.1.16 to 2.3.3

Thank you @Vimal Kumar , I haven't seen these steps documented anywhere before, did I miss it?

 

In the release archive https://magento.com/tech-resources/download there are later versions of the 2.1 and 2.2 releases than you mention, should I stick with the 2.1.18 and 2.2.8 versions you list?

 

How do I handle the PHP versions required by the different versions? Should I change the PHP version to the one required by the one I'm upgrading to before running the upgrade command?

 

I was following method 3 for upgrading from this blog post https://www.goivvy.com/blog/magento-2-upgrade

 

 

Are the upgrade commands there correct and sufficient for the upgrade steps you recommend?

 

Thanks for the help.

 

 

Re: Integrity constraint violation while upgrading 2.1.16 to 2.3.3

Could I get some clarity on my questions about this upgrade path?