Broken upgrade

I have an old site that was on and needs to go on to a box with php7.2 or higher.

I upgraded it to 8.1 and then if I go any further I get this error

An unexpected error occurred.

An exception occurred while executing ‘INSERT INTO CollectionAttributeValues (cID, cvID, akID, avID) VALUES (?, ?, ?, ?)’ with params [“494”, “1”, 5, null]: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (database_name.CollectionAttributeValues, CONSTRAINT FK_BB9995FCA2A82A5D FOREIGN KEY (avID) REFERENCES AttributeValues (avID))

Can anyone help?

I’ve run into errors like this before, here is how I solved them.

  1. On the command line run concrete/bin/concrete5 orm:schema-tool:update --dump-sql
  2. In phpMyAdmin or something similar run SET FOREIGN_KEY_CHECKS=0;
  3. Then copy the output from your CLI and run that

Once that’s done you should be able to do your upgrades as you wish.