Spring boot Spring Boot项目中的Liquibase模块和变量
我在项目中使用liquibase,下面是我的一个配置文件:Spring boot Spring Boot项目中的Liquibase模块和变量,spring-boot,gradle,liquibase,Spring Boot,Gradle,Liquibase,我在项目中使用liquibase,下面是我的一个配置文件: databaseChangeLog: - changeSet: id: 123 author: m.rybalkin changes: - update: columns: - column: name: code value: '123'
databaseChangeLog:
- changeSet:
id: 123
author: m.rybalkin
changes:
- update:
columns:
- column:
name: code
value: '123'
schemaName: prod
tableName: config_bundle
where: code='321'
这是“liquibase”模块的build.gradle:
我的模式有两个不同的名称,一个用于生产的“prod”和一个用于测试的“test”。
是否可以在我的application.yml或build.gradle中设置一个变量,以便在测试和部署应用程序时更改名称
另外,我还有两个不同的Spring应用程序配置文件——“prod”和“test”您当然可以在liquibase运行时添加(可以从gradle直接从命令行等传递)
例如,您可以在CLI上调用liquibase:
液化酶-Durl=更新
group 'com.project.test'
version '0.1.0'
buildscript {
dependencies {
classpath "org.liquibase:liquibase-gradle-plugin:${liqubasePluginVersion}"
classpath "gradle.plugin.com.avast.gradle:gradle-docker-compose-plugin:${gradleDockerComposePluginVersion}"
}
}
apply plugin: 'java'
apply plugin: 'org.liquibase.gradle'
apply plugin: 'com.avast.gradle.docker-compose'
dependencies {
liquibaseRuntime "org.liquibase:liquibase-core:${liquibaseCoreVersion}"
liquibaseRuntime "org.postgresql:postgresql:${postgresqlVersion}"
}
liquibase {
activities {
main {
def file = new File("${projectDir}/liquibase.properties")
if (file.exists()) {
def props = new Properties()
InputStream is = new FileInputStream(file)
props.load(is)
is.close()
changeLogFile props['changeLogFile']
outputFile 'liquibase/sql-migration-bundle.sql'
url props['url']
username props['username']
password props['password']
} else {
println "Add ${projectDir}/liquibase.properties if you want use liquibase plugin"
}
}
dockerPostgres {
changeLogFile "${projectDir}/changelog/changelog-master.yml"
url 'jdbc:postgresql://localhost:5555/test'
username 'test'
password 'test'
}
runList = 'main'
}
}
task localUpdate(dependsOn: "composeUp") {
doFirst {
liquibase.setProperty("runList", "dockerPostgres")
}
finalizedBy update
}
task localDropAll(dependsOn: "composeUp") {
doFirst {
liquibase.setProperty("runList", "dockerPostgres")
}
finalizedBy dropAll
}