gh0st
gh0st

Reputation: 1722

How would one track existing database changes w/ Liquibase?

I'm interested in exercising change control management on my database with liquibase. I've already established a connection and generated a changelog.

What I'm stumbling through now is I can't simply run that changelog I just generated against that same database. It starts to trip up on things like unique constraints already existing.

Is there a way to tell liquibase to ignore these? Or only apply them if they do not exist?

I know there's a flag on createTable changes called ifNotExists. But how would one go about doing the same with addUniqueConstraint?

I'm really hoping that dropping my entire database isn't a solution.

Upvotes: 0

Views: 44

Answers (1)

Tranquilized
Tranquilized

Reputation: 751

You can use pre conditions in your change sets like this:

    <changeSet id="add-table" author="author">

        <preConditions onError="MARK_RAN">
            <not>
                <uniqueConstraintExists tableName="table_name" constraintName="contraint_name" columnNames="column_name" />
            </not>
        </preConditions>

Upvotes: 0

Related Questions