FOREIGN KEY problem on Packages

When trying to install a package, I get errors like this one:

An exception occurred while executing 'ALTER TABLE AttributeSets ADD CONSTRAINT FK_FCA02D5FCE45CBB0 FOREIGN KEY (pkgID) REFERENCES Packages (pkgID)': SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`databasename`.`#sql-1ca9_3504d`, CONSTRAINT `FK_FCA02D5FCE45CBB0` FOREIGN KEY (`pkgID`) REFERENCES `Packages` (`pkgID`))

This is a version 8.2.1 site, but its been upgraded from version 7.x. Probably has something to do with the upgrade I'm guessing.
Really can't find a solution on the forums etc.

View Replies:
JohntheFish replied on at Permalink Reply
Dutchwave replied on at Permalink Reply
But 8.2.1 includes that update by default right, so it should have worked already? Prior to updating to version this install was updated to 5.8.0.x . Could that make the difference?
No luck by trying it manually with the sql dump. Is there a way to run the updates again (without resetting all data)?
Dutchwave replied on at Permalink Reply
Allright finally figured out what he meant.
This worked for me:

run in database SET FOREIGN_KEY_CHECKS=0;
Commandline: concrete/bin/concrete5 orm:schema-tool:update --dump-sql
Copy paste all the output and run it in the database.
run in database SET FOREIGN_KEY_CHECKS=1;