In liquibase-update-to-latest.xml file, there are 2 changesets one drops the existing order_type table and the other adds a new one, there is also 2 changesets that modify the orders table by dropping the existing order_type_id column from orders and adding a new one. Note there is also changesets before that drop and add foreign key constraints where applicable, these also need to be removed where necessary.
We need to keep the changeset that inserts an order_type for test order since it only inserts it if it doesn't exist but we need to remove the one the inserts one for drug orders because it comes as core data with a predifined order_type_id and uuid.
Below are the changeset ids that are involved: (most if not all of them need to be removed)
- We need to revisit this so that instead of dropping the old order_type table and adding a new one, we instead just have to add the new columns java_class_name and parent to the existing order_type table following the scenarios below:
- If the order_type table already has these 2 columns, we assume the admin knows what they are doing i.e they updated the order_type table by adding the new columns and set the valid column values so we do nothing.
- If the 2 columns don't exist and the table contains exactly one row i.e the drug order row then add them and set the java_class_name column of the row to org.openmrs.DrugOrder see the drug order type uuid in liquibase-core-data.xml file, you will need to use the uuid to check if the row exists.
- If none of the above conditions is satisfied, halt the upgrade asking the user to first update their order_type table table before proceeding following the 1.10 upgrade documentation/release notes.
- You will need to add unit tests to Database1_9_7UpgradeTest to test the update scripts work as expected as described in the scenarios above.
- Update CreateDiscontinueOrders.java to set the order_type_id of the new DC orders(should be the same as the one for the previous order)