Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.ritense.valtimo.changelog.repository.ChangesetRepository
import com.ritense.valtimo.changelog.service.ChangelogDeployer
import com.ritense.valtimo.changelog.service.ChangelogService
import com.ritense.valtimo.contract.config.LiquibaseMasterChangeLogLocation
import jakarta.persistence.EntityManager
import org.springframework.boot.autoconfigure.AutoConfiguration
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
Expand Down Expand Up @@ -57,14 +58,16 @@ class ChangelogAutoConfiguration {
@Bean
@ConditionalOnMissingBean(ChangelogDeployer::class)
fun changelogDeployer(
changelogService: ChangelogService,
changesetDeployers: List<ChangesetDeployer>,
environment: Environment,
changelogService: ChangelogService,
changesetDeployers: List<ChangesetDeployer>,
environment: Environment,
entityManager: EntityManager,
): ChangelogDeployer {
return ChangelogDeployer(
changelogService,
changesetDeployers,
environment,
entityManager,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.databind.node.JsonNodeFactory
import com.fasterxml.jackson.databind.node.ObjectNode
import com.ritense.valtimo.changelog.domain.ChangesetDeployer
import jakarta.persistence.EntityManager
import mu.KotlinLogging
import org.springframework.boot.context.event.ApplicationReadyEvent
import org.springframework.context.event.EventListener
Expand All @@ -36,6 +37,7 @@ class ChangelogDeployer(
private val changelogService: ChangelogService,
private val changesetDeployers: List<ChangesetDeployer>,
private val environment: Environment,
private val entityManager: EntityManager
) {
// Create new objectmapper only used for md5 checksum sanitization to prevent config changes from impacting checksum
private val objectMapper: ObjectMapper = JsonMapper
Expand All @@ -51,6 +53,7 @@ class ChangelogDeployer(
logger.info { "Running deployer" }

changesetDeployers.asReversed().forEach { it.before() }
entityManager.flush()

changesetDeployers.forEach { changesetDeployer ->
changelogService.loadResources(changesetDeployer.getPath()).forEach { resource ->
Expand Down