I want to add a unique constraint to my table during it's creation. I thought something like this would work but it seems to just do nothing.
<createTable tableName="MY_TABLE">
   <column name="MY_TABLE_ID" type="SMALLINT" autoIncrement="true">
      <constraints primaryKey="true" nullable="false"/>
   </column>
   <column name="TABLE_FIELD" type="SMALLINT">
      <constraints nullable="false" uniqueConstraintName="TABLE_FIELD_ix1"/>
   </column>
   <column name="TABLE_FIELD_TWO" type="SMALLINT">
      <constraints nullable="false" uniqueConstraintName="TABLE_FIELD_ix1"/>
   </column>
</createTable>
I know I can use the addUniqueConstraint tag (and have successfully used it) after I create the table but I wanted to know if that was avoidable.
Basically I want to do this but during the create table portion
<addUniqueConstraint tableName="MY_TABLE"
                     columnNames="TABLE_FIELD, TABLE_FIELD_TWO"
                     constraintName="TABLE_FIELD_ix1"/>
                Try adding unique="true" to <constraints>.
    <createTable tableName="MY_TABLE">
       <column name="MY_TABLE_ID" type="SMALLINT" autoIncrement="true">
          <constraints primaryKey="true" nullable="false"/>
       </column>
       <column name="TABLE_FIELD" type="SMALLINT">
          <constraints nullable="false" unique="true" uniqueConstraintName="TABLE_FIELD_ix1"/>
       </column>
       <column name="TABLE_FIELD_TWO" type="SMALLINT">
          <constraints nullable="false" unique="true" uniqueConstraintName="TABLE_FIELD_ix2"/>
       </column>
    </createTable>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With