我需要制作一个 Liquibase 迁移脚本,仅当尚未添加主键时才将主键添加到数据库表中。这样做的最佳方法是什么?它会是这样的:
<changeSet id="...">
<preConditions>
(What goes here? Should I use <sqlCheck>, or is there a better alternative?)
</preConditions>
<addPrimaryKey tableName="foo" columnNames="bar" constraintName="foo_pk" />
</changeSet>
Run Code Online (Sandbox Code Playgroud)
答案是……
<preConditions onFail="MARK_RAN">
<not>
<primaryKeyExists tableName="foo" />
</not>
</preConditions>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2042 次 |
| 最近记录: |