Liquibase Maven setup - iamleohandev/myLiquibase GitHub Wiki

Introduction to liquibase setup on maven

Maven-Liquibase-plugin

Step1:

In the pom.xml file add the maven liquibase-core and liquibase-maven-plugin dependencies. The link can be found in Liquibase Mave Repository and the jdbc driver for your database.

    <dependency>
		<groupId>org.liquibase</groupId>
		<artifactId> liquibase-core</artifactId>
		<version>3.2.0</version>
	</dependency>

	<dependency>
		<groupId>org.liquibase</groupId>
		<artifactId>liquibase-maven-plugin</artifactId>
		<version>3.2.0</version>
	</dependency>

	<dependency>
		<groupId>postgresql</groupId>
		<artifactId>postgresql</artifactId>
		<version>9.1-901-1.jdbc4</version>
	</dependency>

Step2: add the plugin

      <plugin>
			<groupId>org.liquibase</groupId>
			<artifactId>liquibase-maven-plugin</artifactId>
			<version>3.2.0</version>
			<configuration>
				<propertyFile>liquibase/liquibase-config.properties</propertyFile>
			</configuration>
			<executions>
				<execution>
					<phase>process-resources</phase>
					<goals>
						<goal>update</goal>
					</goals>
				</execution>
			</executions>
		</plugin>

Step3: add the liquibase configuration file liquibase-config.properties

changeLogFile: liquibase/db.changelog.xml

driver: org.postgresql.Driver

url: jdbc:postgresql://127.0.0.1:5432/hantest

username: postgres

password: Han820429

verbose: true

dropFirst: false

Step4:add the database change log db.changelog.xml

Final step: mvn liquibase:update

⚠️ **GitHub.com Fallback** ⚠️