title: foreignKeyConstraintExists Precondition Seems Not Adequate If Foreign Keys with Same Reference Details but Different Names Exist
body: <p>When I upgrade an existing database using a Liquibase script (<em>the database has never been upgraded by Liquibase</em>), the following error occurs.</p>
  
  <pre><code>liquibase.exception.MigrationFailedException: Migration failed for change set ../master.xml::5::ray.chen:
       Reason: liquibase.exception.DatabaseException: ORA-02275: such a referential constraint already exists in the table
   [Failed SQL: ALTER TABLE CRDM_RCHEN.SOME_TABLE ADD CONSTRAINT SOME_TABLE_FK FOREIGN KEY (COLUMN_2) REFERENCES CRDM_RCHEN.SOME_OTHER_TABLE (COLUMN_1)]
  
          at liquibase.changelog.ChangeSet.execute(ChangeSet.java:605)
          at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
          at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:79)
          at liquibase.Liquibase.update(Liquibase.java:214)
          at liquibase.Liquibase.update(Liquibase.java:192)
          at liquibase.integration.commandline.Main.doMigration(Main.java:1126)
          at liquibase.integration.commandline.Main.run(Main.java:184)
          at liquibase.integration.commandline.Main.main(Main.java:103)
  </code></pre>
  
  <p>I double checked the Liquibase script and the database, a foreign key named <strong>SOME_TABLE_1_FK</strong> already exists in the database. The root cause should be that the Liquibase script is going to add a foreign key named <strong>SOME_TABLE_FK</strong> but a foreign key named <strong>SOME_TABLE_1_FK</strong> already exists with same reference details and different name. It seems the database does not allow 2 foreign keys which names are different but reference details are same.</p>
  
  <p>Do you have any solutions or ideas about this issue? Thanks.</p>
  
  <p>Here is the related Liquibase script. I use the <strong>foreignKeyConstraintExists</strong> precondition to check whether the foreign key <strong>SOME_TABLE_FK</strong> exists, if not, add it; but if there is a foreign key existing with same reference details but different name (<em>the above case</em>), the changeset will be executed and the above error occurs.</p>
  
  <pre><code>&lt;changeSet author="ray.chen" id="5"&gt;
      &lt;preConditions onFail="MARK_RAN"&gt;
          &lt;not&gt;
              &lt;foreignKeyConstraintExists foreignKeyName="SOME_TABLE_FK" /&gt;
          &lt;/not&gt;
      &lt;/preConditions&gt;
      &lt;addForeignKeyConstraint constraintName="SOME_TABLE_FK" baseTableName="SOME_TABLE" baseColumnNames="COLUMN_2" referencedTableName="SOME_OTHER_TABLE" referencedColumnNames="COLUMN_1" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" /&gt;
  &lt;/changeSet&gt;
  </code></pre>