mhmpl
mhmpl

Reputation: 1043

Rename Liquibase changelog tables

I'm using Liquibase (v 3.0.7) together with 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>

Once I've deployed my Spring application, Liquibase will create two tables: databasechangelog and databasechangeloglock. Is there a way to rename those two tables?

Upvotes: 0

Views: 6051

Answers (2)

Yury
Yury

Reputation: 664

Or you can use small workaround to setup this names in spring configuration, check this answer for Java configuration - https://stackoverflow.com/a/50644347 or you can use this for xml configuration

<?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>

Upvotes: 1

Harald Wellmann
Harald Wellmann

Reputation: 12865

You can use system properties to override the default table names.

Upvotes: 1

Related Questions