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

Adding Auto Increment to the Second Key of a Composite Key

$
0
0

Hello,

I am trying to add an auto increment for the second key of my composite key but I am getting an error:

<changeSet author="a1" id="1">

<createTable tableName="AgentDef">

<column name="Tenant_Id" type="VARCHAR(36)">

<constraints primaryKey="true" />

</column>

<column name="AgentId" type="INTEGER" autoIncrement="true">

<constraints primaryKey="true" />

</column>

<column name="AgentName" type="VARCHAR(255)" />

</createTable>

</changeSet>

I am getting the following exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.MigrationFailedException: Migration failed for change set 
     Reason: liquibase.exception.DatabaseException: Incorrect table definition; there can be only one auto column and it must be defined as a key


Noting the following:

- The AgentId field should be kept as the second field in the primary key set and Tenant_Id should be the first field. If I change the order, the exception does not happen and database works fine.


Viewing all articles
Browse latest Browse all 2993

Trending Articles



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