我试图用spring boot和liquibase做一个概念验证应用程序.我基本上想要创建一个可以通过使用名为context的changeset属性管理liquibase更改集的spring boot应用程序,这样没有上下文的changeset可以应用于任何spring引导配置文件,而具有特定上下文的changeset(例如context ="dev")仅当该类型的弹簧引导配置文件处于活动状态时才会应用(例如spring.profiles.active = dev).
在我的应用程序中,我有以下弹簧配置文件 - > dev,prod(每个在应用程序yaml文件中正确指定,并在配置文件下指定了相关配置文件数据库凭据).我需要做些什么来完成这项工作.下面是我的application.yaml
spring:
application:
name: liquibase-spring-jpa-postgres-example
liquibase:
change-log: db.changelog/db.changelog-master.xml
spring:
profiles: dev
datasource:
url: jdbc:postgresql://localhost:5432/dev
username: postgres
password: password
driver-class-name: org.postgresql.Driver
spring:
profiles: ci
datasource:
url: jdbc:postgresql://localhost:5432/ci
username: postgres
password: password
driver-class-name: org.postgresql.Driver
spring:
profiles: qa
datasource:
url: jdbc:postgresql://localhost:5432/qa
username: postgres
password: password
driver-class-name: org.postgresql.Driver
spring:
profiles: production
datasource:
url: jdbc:postgresql://localhost:5432/prod
username: postgres
password: password
driver-class-name: org.postgresql.Driver
Run Code Online (Sandbox Code Playgroud)
以下是当前的databaseChangeLog文件(如果我的弹簧配置文件是prod,则第二个更改集不应该运行).
<changeSet id="20161016_my_first_change" author="fike" context="dev, qa, ci, production">
<sql>
CREATE TABLE customer
(
id BIGSERIAL …Run Code Online (Sandbox Code Playgroud)