title: how to recreate an index if it already exists with liquibase
body: <p>I have a changeset to create an index.</p>
  
  <pre><code>&lt;changeSet author="hilland" id="x-NC-U-y" runOnChange="true"&gt;
      &lt;createIndex indexName="NC-U-y" tableName="x" unique="true"&gt;
          &lt;column name="y"/&gt;
      &lt;/createIndex&gt;      
  
      &lt;rollback&gt;
          &lt;dropIndex .../&gt;
      &lt;/rollback&gt;
  
      &lt;modifySql&gt;
          &lt;append value=" INCLUDE ( [a],[b]) WITH (DATA_COMPRESSION=page)"/&gt;
      &lt;/modifySql&gt;
  &lt;/changeSet&gt;
  </code></pre>
  
  <p>The problem is that an older version of the index <em>might</em> exist (it will on some targets (dev server, with an older version of this index; no includes), will not on others (eg a fresh deploy to an empty database).</p>
  
  <p>Is there a better way to resolve this so that the script becomes universal, than to include a prefix which says</p>
  
  <pre><code>&lt;sql&gt;IF select {sys.indexes.stuff} is not null {drop the index}&lt;/sql&gt;?
  </code></pre>
  
  <p>Ideally there would be a precondition to drop-if-exists the existing index so that it can be recreated, but i don't think that can be done.</p>
  
  <p>What is the best way to handle this situation?</p>
  
  <p>an alternate solution i thought of would be to have a separate changest "if index v1 exists, drop it" then have a separate v2 changeset, but then that would make rollback hard.</p>
  
  <p>I realize that the run on change condition for the changeset makes rollback hard, but the only rollback i'm concerned with in this case is to and from an empty database, although a pattern which easily accommodates rollbacks to previous version would be welcome also.</p>