How to resolve permissible-values.xml changeset failed.

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 the 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:

  1. Take a backup of the original table in case something went wrong.
    create table databasechangelog_bk as select * from databasechangelog;

  2. Remove the existing changesets for ‘db/2.0/permissible-values.xml’.
    delete from databasechangelog where filename='db/2.0/permissible-values.xml';

  3. Insert the correct changesets into databasechangelog table.

    1 2 3 4 5 LOAD DATA LOCAL INFILE '<path_to_file>/permissible-values.csv' INTO TABLE databasechangelog FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
  4. 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.