Page 1 of 1

FEU Upgrade: foreign key constraint fails

Posted: Mon Oct 09, 2017 5:17 pm
by webform
I've got the "fun" task to upgrade a very old CMSMS site from v. 1.7.1. to current version 2.2.3.1.

Mostly it's gone ok but i can't upgrade "Frontend User" (FEU) past v. 1.29. without this error:

Code: Select all

ALTER TABLE cms_module_feusers_properties ADD FOREIGN KEY (title) REFERENCES cms_module_feusers_propdefn (name) Cannot add or update a child row: a foreign key constraint fails (`mb2017`.`#sql-56d_4e`, CONSTRAINT `#sql-56d_4e_ibfk_2` FOREIGN KEY (`title`) REFERENCES `cms_module_feusers_propdefn` (`name`))
Is there a way to fix this problem so i can upgrade FEU to latest version?

Re: FEU Upgrade: foreign key constraint fails

Posted: Mon Oct 16, 2017 8:17 pm
by webform
Anyone has any suggestions how i solve this problem, so i can upgrade FEU to latest version?

I've tried upgrade to nearly every version after 1.29 but i seem stuck on "foreign key constraint" error on every attempt.

Re: FEU Upgrade: foreign key constraint fails

Posted: Mon Oct 16, 2017 8:24 pm
by calguy1000
The error means you have some corrupt data in your properties table.

The upgrade is attempting to create a foreign key relationship that maintains the relationship between property values and property definitions, and there there are one or more values in the properties table that do not match properties that are defined elsewhere.

so, before the upgrade can proceed you will need to find all values in the _properties table who's title is NOT IN the propdefn table, and then remove them.

Re: FEU Upgrade: foreign key constraint fails

Posted: Mon Oct 16, 2017 8:47 pm
by webform
Thanks!

I will run through my tables and see if i can find the offending properties.

Re: FEU Upgrade: foreign key constraint fails

Posted: Tue Oct 17, 2017 12:51 am
by webform
I succeeded finding the corrupt data in the properties table ;D

Out of approx. 9000 records, 4 had a value not present in the propdefn table.

I deleted the 4 records and now i could upgrade FEU to latest version.

Thanks Calguy for pointing me in the right direction.