Unable to get 5.7 site to upgrade

Permalink
I'm not able to get a 5.7 site to upgrade to 8.4 rc2 (or 8.3.2). I get this error:

An exception occurred while executing 'ALTER TABLE atSelectOptionsSelected ADD CONSTRAINT FK_40C97EC3E584C274 FOREIGN KEY (avSelectOptionID) REFERENCES atSelectOptions (avSelectOptionID)': SQLSTATE[HY000]: General error: 1822 Failed to add the foreign key constaint. Missing index for constraint 'FK_40C97EC3E584C274' in the referenced table 'atSelectOptions'

If I try and force the update in the command line using php ./concrete/bin/concrete5 c5:update --rerun from @mlocati's github pull request I get this error:

An exception occurred while executing 'INSERT INTO SystemDatabaseMigrations (version) VALUES (?)' with params ["20140919000000"]:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '20140919000000' for key 'PRIMARY'

There doesn't seem to be a way forward for this site.

Any ideas?

katalysis
 
katalysis replied on at Permalink Reply
katalysis
Now have a similar issue with another site on a different container.

Trying to update from 5.7.5.13 to 8.4 results in the following:

An exception occurred while executing 'ALTER TABLE atSelectOptionsSelected ADD CONSTRAINT FK_40C97EC3E584C274 FOREIGN KEY (avSelectOptionID) REFERENCES atSelectOptions (avSelectOptionID)': SQLSTATE[HY000]: General error: 1005 Can't create table 'admin_totallooks2db.#sql-1cb9_7e8aee' (errno: 150)

It seems some sites that started at older 5.7 versions just don't seem to be able to be upgraded cleanly. Not sure if this is our server database setup or what?
emirii replied on at Permalink Reply
emirii
No, I've been having the same issues for a while now. I just can't update some sites...

I was able to update from Concrete5 7.5.13 to Concrete5 8.1.0 but anything beyond 8.1.0 breaks with integrity errors.

An exception occurred while executing 'INSERT INTO CollectionAttributeValues (cID, cvID, akID, avID) VALUES (?, ?, ?, ?)' with params ["296", "1", 5, null]: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`sandbox_tanz`.`CollectionAttributeValues`, CONSTRAINT `FK_BB9995FCB6561A7E` FOREIGN KEY (`akID`) REFERENCES `AttributeKeys` (`akID`))


I can't figure out how to solve the error. My entire site breaks when I try.
katalysis replied on at Permalink Reply
katalysis
BACKUP before trying this...

We've had this happen to three or four sites now and usually managed to work though the issue by deleting the various bits of each offending attribute in the database.

You'll find that deleting the attribute value is prevented by foreign key constraints so you have to work down though the associated tables until you get to a row you can delete and then you'll be able to work back up until you can delete the one causing the error.

Once you've done this the chances are you'll get a similar error on another attribute - we've normally had to clear 4 or 5 before the site starts to work.

There is no guarantee this will work and there is a good chance of breaking the site permanantly so BACKUP FIRST and be ready to restore!