I managed to integrate Liquibase into our Maven assembly to initialize the H2 inmemory database with several enrys. These rows have a primary key generated using a sequence table that works as expected (BigInt increments values ββstarting from 1).
My problem is that when I try to save a new object in this table from the Junit integration test, I get a "unique key constraint violation" because this new object has the same primary key as the first row inserted with Liquibase changelog -xmls.
So, initialization works just fine, as expected. The maven assembly uses the changelog-xmls linibase file
At the moment, Iβm just completely clearing the corresponding tables before any integration tests with my own Runner ... but this will not be possible in the future. Its currently quite a chalet to investigate such problems since there is as yet no detailed information about Liquibase.
Update workaround
While the identifier prefers to respond lower using H2, a problem arises that does not work below the set of changes because the required minValue is not supported.
<changeSet author="liquibase-docs" id="alterSequence-example">
<alterSequence
incrementBy="1"
maxValue="371717"
minValue="40"
ordered="true"
schemaName="public"
sequenceName="seq_id"/>
As a simple workaround, now just discard the existing sequence that was used to insert my test data into the second changeSet:
<changeSet id="2" author="Me">
<dropSequence
sequenceName="SEQ_KEY_MY_TBL"/>
<createSequence
sequenceName="SEQ_KEY_MY_TBL"
incrementBy="1"
startValue="40"/>
</changeSet>
, , - *. xml, 1. 30 , 1-30. . , Junit, , 40, .
Not H2, , , minValue/maxValue, .
Update:
, , , , H2 Liquibase, DB-Init?