Liquibase
Introduction
Setup
Gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.liquibase:liquibase-core:4.25.1'
}
}
plugins {
id 'java'
id 'org.springframework.boot' version '4.0.2'
id 'io.spring.dependency-management' version '1.1.7'
// apply liquibase to the command list
id 'org.liquibase.gradle' version '3.1.0'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
description = 'Gradle Playground'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "2025.1.0")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'org.liquibase:liquibase-core'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test'
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
liquibaseRuntime 'org.liquibase:liquibase-core:4.25.1'
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:4.0.1'
liquibaseRuntime 'org.postgresql:postgresql:42.7.1'
liquibaseRuntime 'info.picocli:picocli:4.7.5'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
// Liquibase script setting
liquibase {
activities {
main {
changelogFile 'src/main/resources/db/changelog/db.changelog-master.yaml'
url 'jdbc:postgresql://localhost:5433/postgres'
username 'postgres'
password 'admin'
driver 'org.postgresql.Driver'
}
// Activity for generateChangeLog - outputs current DB schema
generate {
changelogFile 'src/main/resources/db/changelog/changes/generated-changelog.yaml'
url 'jdbc:postgresql://localhost:5433/postgres'
username 'postgres'
password 'admin'
driver 'org.postgresql.Driver'
}
}
runList = project.hasProperty('runList') ? project.runList : 'main'
}
tasks.named('test') {
useJUnitPlatform()
}Maven
Migration Script
Master
Example Creation Script
Example Update Script
Commands
Last updated