RA-865: Enable running OpenMRS 2.x on H2 database

Pull requests are coming through for this ticket regarding upgrading module’s to use liquibase instead of sqldiff in modules (and to remove any references within liquibase).

Looks like the reason for this is to allow one to run OpenMRS against H2? If this will help with making sure our database upgrade scripts are stable and well-tested, I’m in support of it, because currently our ability to test our changsets is pretty weak–but, unfortunately, this makes the testing burden on these new pull requests rather high.

At a minimum, we need to test the start-up of each module against a clean, empty OpenMRS database, and against an existing OpenMRS DB that already has all the changes within the changeset applied (one pull request I see I’m 90% sure will fail in this use case because it modifies an existing liquibase changeset, which should give a checksum error). Ideally, changes should be tested at each stage as well–for instance if there are 3 changesets that are modified, then it should be tested against a DB that already has the first changeset applied, but not the second and third, and then one that has the first and second, but not the third applied (if those changesets were initialized added at different dates). And, unfortunately, this doesn’t put us 100% in the clear because it doesn’t guarantee that there won’t be slight differences that could cause problems in future changesets (notoriously, around differences in foreign key names).

Anyway, all these issues may actually be more reasons to support this change, if it will make things easier going forward, but we need make sure we test all these properly–ideally a module owner wouldn’t have to go through all the above steps and some sort of test case/verification could be included in the pull request? I don’t know if there are any automated tools we could use?

I’ll add that it’s not only about supporting H2, but virtually any DB that is supported by liquibase including PostgreSQL, Oracle, etc.

Some time ago I coded up a way to test liquibase changesets for openmrs-core and I will try to make it useful for modules too. See

Of course do not accept pull requests unless you know for sure that they work as expected, which also means that you can ask for adding tests :smile: Currently, @dmytro_trifonov is taking the first pass on this, trying to make OpenMRS 2.x start on H2. Once that succeeds we will polish off pull requests adding necessary tests.

1 Like

HI @raff @mogoodrich

while I was working on Trunk-5400 we were discussing that a database Upgrade test for 2.2.0 is may necessary or would be helpful.

	public final static String DATABASE_PATH = TEST_DATA_DIR + "openmrs-1.9.7.h2.db";

I noticed that you were creating for the 1.9 test a H2 file that will be used by the upgrade test. I am wodering how did you created that file? Because as I assume it should be created based on the Hibernate specifications?

I need such a H2 file to implement the Upgrade test for version 2.2.0 as discussed in the ticket.