我正在使用 Liquibase(v 3.0.7)和 Spring(v 4.0.0):
<!-- Liquibase configuration -->
<bean id = "liquibase" class = "liquibase.integration.spring.SpringLiquibase">
<property name = "dataSource" ref = "dataSource" />
<property name = "changeLog" value = "classpath:database/changelog.xml" />
</bean>
一旦我部署了Spring应用程序,Liquibase将创建两个表:databasechangelog
和databasechangeloglock
。有没有办法重命名这两个表?
答案 0 :(得分:1)
您可以使用system properties覆盖默认表名。
答案 1 :(得分:1)
或者您可以使用小解决方法在spring配置中设置此名称,请查看Java配置的答案 - https://stackoverflow.com/a/50644347或者您可以将其用于xml配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<bean id="liquibaseSystemPropsSetter"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" value="#{@systemProperties}"/>
<property name="targetMethod" value="putAll"/>
<property name="arguments">
<util:properties>
<prop key="liquibase.databaseChangeLogTableName">${application.liquibase.change.log.table.name}</prop>
<prop key="liquibase.databaseChangeLogLockTableName">${application.liquibase.change.log.lock.table.name}
</prop>
</util:properties>
</property>
</bean>
<bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase"
depends-on="liquibaseSystemPropsSetter"
p:dataSource-ref="localDataSource"
p:changeLog="classpath:${application.liquibase.change.log.path}"
p:shouldRun="${application.liquibase.should.run}"/>
</beans>