How do I make an insert for PostgreSQL using Liquibase if my ids are sequential. I try with the following:
<changeSet author="rparente" id="service-1.1-2019-01-09-01">
<insert tableName="tenant">
<column name="id"defaultValueSequenceNext="hibernate_sequence"/>
<column name="description" value="Prueba"/>
<column name="name" value="antel"/>
<column name="service_id" value="antel"/>
</insert>
</changeSet>
and I try with
<changeSet author="rparente" id="service-1.1-2019-01-09-01">
<insert tableName="tenant">
<column name="id" value="nextval('hibernate_sequence')"/>
<column name="description" value="Prueba"/>
<column name="name" value="antel"/>
<column name="service_id" value="antel"/>
</insert>
</changeSet>
The error is:
ERROR: null value in column "id" violates not-null constraint
I found the solution to insert data in Postgres with sequence (no default) ids
<changeSet author="author_name" id="service-1.1-2019-01-09-01">
<insert tableName="tenant">
<column name="id" valueSequenceNext="name_sequence"/>
<column name="description" value="TEST"/>
<column name="name" value="test"/>
<column name="service_id" value="testl"/>
<column name="status" value="ACTIVE"/>
</insert>
</changeSet>
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