无法使用 Liquibase 中的序列在 table 中插入值
Unable to insert values in a table using sequence in Liquibase
我想使用 sequence_name.NEXTVAL 自动计算 liquibase 中的列值。后端数据库是postgresql。我尝试使用 "valueComputed" 属性,如 this link 所示。但它不是使用序列计算值,并且列的值在插入时为空。我们如何使用序列自动增加 liquibase 中的列?提前谢谢你的帮助。
我的代码如下:
<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>
这对我有用:
<createTable tableName="tablename">
<column name="id" type="bigint" defaultValueSequenceNext="seq_name">
<constraints primaryKey="true" nullable="false"/>
</column>
</createTable>
我想使用 sequence_name.NEXTVAL 自动计算 liquibase 中的列值。后端数据库是postgresql。我尝试使用 "valueComputed" 属性,如 this link 所示。但它不是使用序列计算值,并且列的值在插入时为空。我们如何使用序列自动增加 liquibase 中的列?提前谢谢你的帮助。
我的代码如下:
<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>
这对我有用:
<createTable tableName="tablename">
<column name="id" type="bigint" defaultValueSequenceNext="seq_name">
<constraints primaryKey="true" nullable="false"/>
</column>
</createTable>