问题
I want to create a check constraint on a table using liquibase, this is the check constaint :
alter table userprefs add constraint chk_null CHECK (updatedate IS NOT NULL OR updateuser IS NOT NULL);
I googled about it but all I can find is how to create the check constraint on a column.
How this is can be done on liquibase ?
回答1:
Liquibase does not support check constraints "natively". You need to put that into a <sql>
tag:
<changeSet author="ichigo" id="1">
<sql>
alter table userprefs add constraint chk_null
CHECK (updatedate IS NOT NULL OR updateuser IS NOT NULL);
</sql>
</changeSet>
来源:https://stackoverflow.com/questions/48460576/check-constraint-on-table-in-liquibase