no

How to Run a Liquibase Job as a Maven Build

When liquibase is integrated into a maven project we can take advantage of the liquibase maven plugin to create a maven build for us. This w...

When liquibase is integrated into a maven project we can take advantage of the liquibase maven plugin to create a maven build for us. This will run the changesets over a database.

1. Liquibase Plugin

First, we need to add the liquibase plugin to our maven project.

<plugin>
	<groupId>org.liquibase</groupId>
	<artifactId>liquibase-maven-plugin</artifactId>
	<version>3.5.3</version>
	<configuration>
		<changeLogFile>${liquibase.changeLogFile}</changeLogFile>
		<driver>${db.driver}</driver>
		<url>${db.url}</url>
		<defaultSchemaName>${db.schema}</defaultSchemaName>
		<username>${db.username}</username>
		<password>${db.password}</password>
		<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
		<expressionVariables>
			<db.schema>${db.schema}</db.schema>
		</expressionVariables>
	</configuration>
</plugin>
Take note of the variables.

2. Create a Build Configuration

This will depend on your IDE, but for this example, we will use IntelliJ.

2.1 Add a new maven run/debug configuration with the following details:


This liquibase build is for an open-source project I've been working with:  https://github.com/meveo-org/meveo.

2.2 Make sure to set each of the environment variables.


2.3 And if you're wondering how the maven profile looks like:

We configure the root changeset file, which for this configuration is rebuilt.
<profile>
	<id>rebuild</id>
	<properties>
		<liquibase.changeLogFile>src/main/db_resources/changelog/db.rebuild.xml</liquibase.changeLogFile>
	</properties>
</profile>

Related

database-version-control 8148926555656593406

Post a Comment Default Comments

item