Reputation: 68
I'm defining the architecture for a new service which will utilize Spring Boot. I'm looking for a way to configure Liquibase deployments to execute only with a certain profile active. I'd also like to disable all other components if possible, to avoid actions from the service logic before the database deployment is complete.
I've successfully started up my service, and seen my changesets execute. I'm not sure of a way other than extreme profile manipulation of all components to make my Liquibase profile be an isolated execution, avoiding instantiation of components in the application context.
Here's my configuration:
spring:
application:
name: liquibase-spring-postgres-example
liquibase:
enabled: false
---
spring:
profiles: dev
datasource:
username: ${service_user}
password: ${DATASOURCE_DB_PASS}
url: jdbc:postgresql://{db}:{port}/schema
liquibase:
url: jdbc:postgresql://{db}:{port}/schema
---
spring:
profiles: liquibase
datasource:
## provided to get spring boot to start up
url: jdbc:postgresql://{db}:{port}/schema
liquibase:
user: ${liquibase_user}
password: ${LIQUIBASE_DB_PASS}
contexts: release
enabled: true
I have tried disabling things like the embedded jetty server successfully with help from a comment I found here:
spring:
...
main:
web-application-type: none
Are there methods aside from extreme profile definition for all beans, or running Liquibase manually outside of Spring Boot to make this possible?
Upvotes: 0
Views: 358
Reputation: 4952
To execute scripts against spring-boot jar file something like this should help you:
java -cp /path/to/spring-boot-fat.jar \
-Dloader.system=true \
-Dloader.main=liquibase.integration.commandline.Main \
org.springframework.boot.loader.PropertiesLauncher \
--changeLogFile=db/changelog/db-changelog-master.xml \
--driver=org.h2.Driver \
--url="jdbc:h2:~/h2db/liquibase-test;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" \
--password=sa \
--username=sa \
updateSQL
edit: this was tested against spring-boot 1.5.x but I guess it should work againsta 2.x too.
Upvotes: 2