Skip to content
Advertisement

Custom LiquibaseDataTypes not found in docker image classpath

I am trying to build a custom Liquibase docker image (based on the official liquibase/liquibase:4.3.5 image) for running database migrations in Kubernetes.

I am using some custom types for the database which are implemented using @DataTypeInfo annotation and extending existing LiquibaseDataTypes like liquibase.datatype.core.VarcharType (class discovery is implemented using the META-INF/services/liquibase.datatype.LiquibaseDatatype mechanism introduced in Liquibase 4+).

These extensions are implemented inside their own maven module called “schema-impl”, which is generating a schema-impl.jar. Everything was working fine when using migrations integrated inside the app startup process, but now we want this to be done by the dedicated docker image.

The only information in the Liquibase documentation regarding this topic is the “Drivers and extensions” section from this document. According to this, I added the schema-impl.jar into the /liquibase/classpath directory during the image building process and also modified the liquibase.docker.properties in order to add this jar file explicitly inside the classpath property:

classpath: /liquibase/changelog:/liquibase/classpath:/liquibase/classpath/schema-impl.jar
liquibase.headless: true

However, when I try to run my changesets with the docker image, I am always getting an error because it cannot find the custom type definition:

liquibase.exception.DatabaseException: ERROR: type "my-string" does not exist

Any help would be really appreciated. Thanks in advance.

Advertisement

Answer

Ok I found it. Basically the problem was that I needed to include the classpath in the entrypoint command, not in the liquibase.docker.properties file (which seems to be useless for this usecase), like this:

--classpath=/liquibase/changelog:/liquibase/classpath/schema-impl.jar
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement