Skip to content

Commit

Permalink
chore(dependencies): upgrade liquibase to 4.24.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kirangodishala committed Nov 13, 2023
1 parent 5403c6a commit 3aecb75
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.netflix.spinnaker.kork.sql.config

import liquibase.GlobalConfiguration

/**
* Defines the configuration properties for connecting to a SQL database for schema migration purposes.
*
Expand All @@ -23,11 +25,14 @@ package com.netflix.spinnaker.kork.sql.config
* @param password The password to authenticate the [user]
* @param driver The JDBC driver name
* @param additionalChangeLogs A list of additional change log paths. This is useful for libraries and extensions.
* @param duplicateFileMode flag to handle if multiple files are found in the search path that have duplicate paths.
*/
data class SqlMigrationProperties(
var jdbcUrl: String? = null,
var user: String? = null,
var password: String? = null,
var driver: String? = null,
var additionalChangeLogs: List<String> = mutableListOf()
var additionalChangeLogs: List<String> = mutableListOf(),
var duplicateFileMode: GlobalConfiguration.DuplicateFileMode = GlobalConfiguration.DUPLICATE_FILE_MODE.defaultValue

)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package com.netflix.spinnaker.kork.sql.migration

import com.netflix.spinnaker.kork.sql.config.SqlMigrationProperties
import liquibase.GlobalConfiguration
import liquibase.Scope
import javax.sql.DataSource
import liquibase.integration.spring.SpringLiquibase
import org.springframework.jdbc.datasource.SingleConnectionDataSource
Expand All @@ -41,6 +43,7 @@ class SpringLiquibaseProxy(
init {
changeLog = "classpath:db/changelog-master.yml"
dataSource = createDataSource()
labelFilter = "test" // this field is added to align with Liquibase versions 4.21.0 and above
}

/**
Expand All @@ -52,18 +55,20 @@ class SpringLiquibaseProxy(
super.afterPropertiesSet()

// Then if anything else has been defined, do that afterwards
(sqlMigrationProperties.additionalChangeLogs + korkAdditionalChangelogs)
.map {
SpringLiquibase().apply {
changeLog = "classpath:$it"
dataSource = createDataSource()
resourceLoader = this@SpringLiquibaseProxy.resourceLoader
shouldRun = !sqlReadOnly
Scope.child(GlobalConfiguration.DUPLICATE_FILE_MODE.key, sqlMigrationProperties.duplicateFileMode) {
(sqlMigrationProperties.additionalChangeLogs + korkAdditionalChangelogs)
.map {
SpringLiquibase().apply {
changeLog = "classpath:$it"
dataSource = createDataSource()
resourceLoader = this@SpringLiquibaseProxy.resourceLoader
shouldRun = !sqlReadOnly
}
}
}
.forEach {
it.afterPropertiesSet()
}
.forEach {
it.afterPropertiesSet()
}
}
}

private fun createDataSource(): DataSource =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Import
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit.jupiter.SpringExtension
import strikt.api.expectThat
import strikt.assertions.isA
Expand All @@ -43,6 +44,7 @@ import strikt.assertions.isNotNull
"sql.enabled=true",
"sql.migration.jdbcUrl=jdbc:h2:mem:test",
"sql.migration.dialect=H2",
"sql.migration.duplicateFileMode=WARN",
"sql.connectionPool.jdbcUrl=jdbc:h2:mem:test",
"sql.connectionPool.dialect=H2"
]
Expand Down
3 changes: 3 additions & 0 deletions kork-sql/src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ sql:
jdbcUrl: "jdbc:h2:mem:test"
user:
password:
duplicateFileMode: WARN
secondaryMigration:
jdbcUrl: "jdbc:h2:mem:test"
user:
password:
duplicateFileMode: WARN
---

spring:
Expand All @@ -52,3 +54,4 @@ sql:
jdbcUrl: "jdbc:h2:mem:test"
user:
password:
duplicateFileMode: WARN
8 changes: 6 additions & 2 deletions spinnaker-dependencies/spinnaker-dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ dependencies {
// containing `afterColumn` construct, with a validation error for postgresql. So pin with 3.10.3
api("org.liquibase:liquibase-core"){
version {
strictly "3.10.3"
strictly "4.24.0"
}
}
api("org.objenesis:objenesis:2.5.1")
Expand All @@ -204,7 +204,11 @@ dependencies {
// when we upgrade to spring boot 2.6.x. It's safe to upgrade beyond 1.29
// with spring boot >= 2.6.12. See
// https://github.com/spring-projects/spring-boot/issues/32228#issue-136185850.0.
api("org.yaml:snakeyaml:1.27")
api("org.yaml:snakeyaml"){
version {
strictly "1.30"
}
}
api("org.springdoc:springdoc-openapi-webmvc-core:${versions.openapi}")
api("org.springdoc:springdoc-openapi-kotlin:${versions.openapi}")
api("org.springframework.boot:spring-boot-configuration-processor:${versions.springBoot}")
Expand Down

0 comments on commit 3aecb75

Please sign in to comment.