I want to use sequence_name.NEXTVAL to automatically compute a column's value in liquibase. The backend database is postgresql. I tried to use "valueComputed" attribute as shown in this link. But it is not computing value using sequence and column's value is null at the time of insertion. How can we auto increment a column in liquibase using a sequence? Thank you for your help in advance.
My code is as below :
<changeSet id="20151020000" author="jhipster">
<createSequence cycle="false" incrementBy="1" maxValue="1000" minValue="50" sequenceName="seq_name" startValue="50"/>
<createTable tableName="tablename">
<column name="id" type="bigint" valueComputed ="seq_name.NEXTVAL">
<constraints primaryKey="true" nullable="false"/>
</column>
</createTable>
This worked for me:
<createTable tableName="tablename">
<column name="id" type="bigint" defaultValueSequenceNext="seq_name">
<constraints primaryKey="true" nullable="false"/>
</column>
</createTable>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With