Check constraint on table in liquibase

≯℡__Kan透↙ 提交于 2021-02-16 21:07:17

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!