views:

160

answers:

1

Hi,

I've added the future-rollback tag to my ant script. What i want to do (and I think future-rollback is what Im looking for) is to generate an sql rollback script, but without executing it (rollback script must be delivered with sql scripts is the requirement from my client).

My changelog file has many changesets, some of which contain the <sqlFile> tag.

For example:

<databaseChangeLog ...>

<include file="latest/somesqlprocedure.xml" relativeToChangelogFile="true"/>

</databaseChangelog...>

Where the latest/somesqlprocedure.xml has an sqlFile tag.

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd"&gt;

<sqlFile path="${changelog.dir}/latest/myprocedure.sql" splitStatements="false" />

</changeSet>

</databaseChangeLog>

When I run the ant script, I get the following error

liquibase.exception.ChangeLogParseException: Invalid Migration File: <sqlfile path=${changelog.dir}/latest/myprocedure.sql> - Could not find file

Does anyone has an idea of whats going on ?

This is a snippet of the build.xml file

<target name="db-future-rollback" depends="init">
        <rollbackFutureDatabase
                    changeLogFile="${db.changelog.file}"
                    driver="${database.driver}"
                    url="${database.url}"
                    username="${database.username}"
                    password="${database.password}"
                    outputfile="${database.rollback.dir}"
                    promptOnNonLocalDatabase="${prompt.user.if.not.local.database}"
                    classpathref="project.classpath"
                    >
            </rollbackFutureDatabase>

    </target>

Thanks in advance.

A: 

The problem may be coming from using an absolute path in your sqlFile, rather than a classpath-relative path. The classpath relative path was what was originally supported in liquibase and is still better tested. The absolute path option was added recently, and the futureRollbackSql code may have not been patched to support it.

Can you try the sqlFile using a relative path?

As a side note, the relative path option is generally better because the filename is used in the databasechangelog table to note which changeSets have ran. If you use an absolute path, the entire path is stored and if you try to re-run the changelog from a different path (or running against the same database from a different machine), liquibase will think it is a different changeSet and try to re-run it.

Nathan Voxland