I'm creating a link table which has 3 columns; id, product_id, tournament_id.
Adding a uniqueConstraint to the "id" column is trivial, but I want to ensure that any pair of (product_id, tournament_id) is unique.
The example at Liquibase.org shows
<changeSet author="liquibase-docs" id="addUniqueConstraint-example">
<addUniqueConstraint catalogName="cat"
columnNames="id, name"
constraintName="const_name"
deferrable="true"
disabled="true"
initiallyDeferred="true"
schemaName="public"
tableName="person"
tablespace="A String"/>
</changeSet>
but is it possible to accomplish this within a <createTable>
block?
Also, just to confirm; does this create a composite unique constraint on the two columns, or does it create two separate unique constraints?
I am pretty certain that:
liquibase update
you would run liquibase updateSQL
.