The below error may occur when upgrading OpenSpecimen from v6.1 to the latest versions. This error comes because of mismatching of author/id/md5sum values present for ‘db/2.0/permissible-values.xml’ changeset in databasechangelog table.
Reason: liquibase.exception.DatabaseException: Cannot add or update a child row: a foreign key constraint fails (`openspecimen_test`.`catissue_permissible_value`, CONSTRAINT `FK57DDCE1FC56C2B1` FOREIGN KEY (`PUBLIC_ID`) REFERENCES `catissue_cde` (`PUBLIC_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION)
To resolve the issue we need to manually add the correct ‘db/2.0/permissble-values.xml’ changesets using below steps:
Download permissible-values.xml file containing the correct changesets values on the database server.
Steps:
Take a backup of the original table in case something went wrong.
create table databasechangelog_bk as select * from databasechangelog;
Remove the existing changesets for ‘db/2.0/permissible-values.xml’.
delete from databasechangelog where filename='db/2.0/permissible-values.xml';
Insert the correct changesets into databasechangelog table.
LOAD DATA LOCAL INFILE '<path_to_file>/permissible-values.csv' INTO TABLE databasechangelog FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
The output of the following should be 26.
select count(*) from databasechangelog where filename='db/2.0/permissible-values.xml';
Once all steps performed, restart the OpenSpecimen.