我有一个像 liquibase 中那样有 2 列的表。
- column:
name: col1
type: UUID
constraints:
nullable: true
references: 'tab1(id1)'
foreignKeyName: 'fk_col1'
- column:
name: col2
type: UUID
constraints:
nullable: true
references: 'tab2(id2)'
foreignKeyName: 'fk_col2'
我想对其中 2 列定义复合非空检查,至少 1 列非空。我发现这里回答了一个类似的查询:两列上的复合非空约束但是,这涉及添加
addCheckConstraint
(https://docs.liquibase.com/change-types/add-check-constraint.html) )在 Postgresql 中。我们没有专业许可证,因此我们无法使用它,是否有其他方法可以添加此条件?
<changeSet id="uniqueId" author="yourname">
<addCheckConstraint
tableName="table_name"
constraintName="chk_col1_or_col2_not_null"
checkConstraint="col1 IS NOT NULL OR col2 IS NOT NULL"/>
</changeSet>