A small problem in openmrs-sdk-maven-plugin build-distro phase

Hello People, I am using openmrs-sdk-maven-plugin to package my distro and then using openmrs-sdk:run to test my packaged distro.

While packaging the distro, I am mentioning a base dbSql as well. This base dbSql gets copied as <targetDir>/dbdump/dump.sql. While this command works fine when I try to provide this SQL file as -DdbSql=<targetDir>/dbdump/dump.sql to openmrs-sdk:run, it fails with an error saying:

Failed to import database: Error executing: DELETE FROM openmrs.global_property WHERE property = ‘search.indexVersion’ [ERROR] . Cause: org.apache.ibatis.jdbc.RuntimeSqlException: Line missing end-of-line terminator (; ) => DELETE FROM openmrs.global_property WHERE property = ‘search.indexVersion’

While debugging the openmrs-sdk I figured out as part of copying the dump we add a query to delete the search.indexVersion property to every dump. Here is the line which does that. This query has the semicolon missing which is causing the dump to fail. Here is the link to the query.

I feel this is a bug, and I can raise a quick fix for this unless anyone else thinks otherwise.

CC: @dkayiwa @mksd

Can you create a ticket for this?

Sure, I will do that and raise a PR.

@dkayiwa Here is the card. For some reason I don’t get exact options to specify in components section and this leads to all the cards being created as TRUNK instead of SDK/RA.

I have moved it to the OpenMRS SDK JIRA project.

@mddubey which version of mysql could this be happening so as i can try to see whether i can reproduce the same bug?

@dkayiwam thanks for moving it.

@herbert24 When running the setup command I am choosing 2nd option for the database which is:

MySQL 5.6 in SDK docker container (requires pre-installed Docker)

Below is the offending line in the dump.sql:

DELETE FROM `openmrs`.global_property WHERE property = 'search.indexVersion'

Let me know if there are more questions.

1 Like

great this communicates to me well

@dkayiwa @herbert24

While I have fixed this issue and it works in my local, I see as part of BuildDistro it always assumes the database name to be openmrs. Line number 361 & 46 are hardcoding the Db name to OpenMRS. Looks like it was never meant to be any other database name other than openmrs.

That is a dump file of a database named openmrs. The reason why this string was parameterised is simply because the database name will not always be openmrs as you can clearly see from here.

@dkayiwa @herbert24

Raised a PR here for the current fix. https://github.com/openmrs/openmrs-sdk/pull/154

However, I feel as part of BuildDistro we should be able to provide a parameterized database name and use that while generating the extra lines for dump.

Let me know your thoughts.

Test it out and see if it adds any value.