Quantcast
Channel: Liquibase Forums
Viewing all articles
Browse latest Browse all 2993

Auto-Increment Precondition

$
0
0
Some of my databases have an auto-increment on the id column of my log table, while others don't. As I need this auto-increment on all of my databases, I created a changeSet like this:

  1.     <changeSet id="1" author="emi">
  2.         <addAutoIncrement columnDataType="int"
  3.                 columnName="id"
  4.                 incrementBy="1"
  5.                 startWith="1"
  6.                 tableName="log"/>
  7.     </changeSet>

However, this fails when I run it on my databases that already have this auto-increment.

I'd like something like this:

  1.     <changeSet id="1" author="emi">
  2.         <preConditions>
  3.                   <not>
  4.                         <autoIncrementExists columnName="id"
  5.                               tableName="log"/>
  6.                   </not>
  7.         </preConditions>
  8.         <addAutoIncrement columnDataType="int"
  9.                 columnName="id"
  10.                 incrementBy="1"
  11.                 startWith="1"
  12.                 tableName="log"/>
  13.     </changeSet>

Is this possible in any way?

PS: If you're wondering why I ended up with this inconsistency on my databases, it's because MySQL deletes the auto-increment when you change a column type, while PostgreSQL doesn't.

Viewing all articles
Browse latest Browse all 2993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>