title: Liquibase alter column constraints
body: <p>I want to start with a specific example where a table is created with a column having a constraint indicating this column is a foreign key:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;changeSet id="1" author="A1"&gt;
      &lt;createTable tableName="TABLE_A"&gt;
          &lt;!-- Other columns --&gt;
          &lt;column name="FK_TABLE_B" type="BIGINT"&gt;
              &lt;!-- the 'TABLE_B' will be renamed soon ! --&gt;
              &lt;constraints references="TABLE_B(ID_PK)"
                  foreignKeyName="JUST_UNIQUE_I_GUESS" nullable="false" /&gt;
          &lt;/column&gt;
      &lt;/createTable&gt;
  &lt;/changeSet&gt;
  </code></pre>
  
  <p>Now a first question: Assume TABLE_B would be renamed to TABLE_NEW... how would i want to change the above constraint so it points to the renamed Tables column ID_PK?</p>
  
  <p>I see a few possibilities:</p>
  
  <ul>
  <li>modify the changeSet itself (no Problem with a H2 inMemory DB... but cmon... thats not the idear right?)</li>
  <li>Drop the whole column in my own changeSet and add it again with the new constraint which could make sence since the column name will probably change to FK_TABLE_NEW anyways... but thats not a real possibilitie for a productive environment</li>
  <li>somehow alter that constraint -> BUT HOW!? the documentation is no
  help at all...</li>
  </ul>
  
  <p>The next question then is why to have this way of constraints if there is a </p>
  
  <pre><code>&lt;addForeignKeyConstraint ...&gt;
  </code></pre>
  
  <p>as well?</p>
  
  <p>So currently i dont feel Liquibase at all just because this was my very first try to change an existing changeSet and my biggest question is: Is this a issue of not understanding the best practise or acctually a problem of the "not so verbouse" documentation?</p>
  
  <p>Thanks for any help!</p>
  
  <p><strong>What i tried</strong></p>
  
  <p>assumed above constraints definition somehow leads to the same as a when done with a</p>
  
  <pre><code>&lt;addForeignKeyConstraint ...&gt;
  </code></pre>
  
  <p>tag but with less attributes. So i thought i could just use the </p>
  
  <pre><code>&lt;dropForeignKeyConstraint ...&gt;
  </code></pre>
  
  <p>tag first delete the ForeignKeyConstraint and then add a new one. But it still tells me it wont find table TABLE_B when trying to execute the first changeSet in a H2 in-memory DB. </p>
  
  <p>My Changeset looked like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;changeSet id="1" author="A2"&gt;
      &lt;dropForeignKeyConstraint baseTableName="TABLE_A"
          constraintName="JUST_UNIQUE_I_GUESS" /&gt;
  
      &lt;addForeignKeyConstraint
          constraintName="JUST_UNIQUE_I_GUESS"
          referencedTableName="TABLE_NEW" baseColumnNames="FK_TABLE_B"
          baseTableName="TABLE_A" referencedColumnNames="ID_PK" /&gt;
  &lt;/changeSet&gt;
  </code></pre>
  
  <p><strong>Background Information</strong></p>
  
  <p>Since were currently just building a POC using a in-memory DB only (H2) its no big deal to just change the first changeSet until we have quite of a final scheme-state... but how to deal with such things if you already have a existing DB, millions of entrys and stuff? Currently i highly doubt Liquibase is the right decision for a company with 1k+ developpers without hiring Liquibase Experts... </p>