liquibase 新手。我有一个由 hibernate 管理的现有架构。我现在需要删除一些表,并且我正在使用 liquibase。我编写了一个配置,成功删除了表。
但我希望仅当表存在时才运行检查,因为新安装的系统不会有该表,因为 hibernate 映射对象不再存在。
我尝试添加一个前提条件。但是,我的日志仍然表明 liquibase 失败,因为它尝试删除该表但它不存在。我做错了什么?我正在使用 Spring Boot/Java
databaseChangeLog:
- preConditions:
on-fail: mark_ran
on-error: mark_ran
tableExists:
tableName: some_old_table
schemaName: public
- changeSet:
id: 01_del_old_table
author: some-dev-01
comment: Remove old table
changes:
- dropTable:
tableName: some_old_table
日志中出现错误:表 public.some_old_table 不存在 ...
PreconditionFailedException
这就像 ti 正在检查先决条件...但仍然未通过。
也尝试过
databaseChangeLog:
- changeSet:
id: zzchange-1.0-remove-xczczxc
author: zzzz
comment: Remove some_old_table table - no longer needed
preConditions:
on-fail: mark_ran
tableExists:
tableName: some_old_table
changes:
- dropTable:
tableName: some_old_table
最佳答案
问题在于 on-fail
属性拼写不正确。 on-fail
应为 onFail
。
正如 @Julian 提到的,最好将一个前提条件置于特定的更改集范围内,并且注释应该在前提条件之后,尽管这不是这里的问题。
databaseChangeLog:
- changeSet:
id: zzchange-1.0-remove-xczczxc
author: zzzz
preConditions:
onFail: mark_ran
tableExists:
tableName: some_old_table
comment: Remove some_old_table table - no longer needed
changes:
- dropTable:
tableName: some_old_table
关于java - 如果表存在则跳过 liquibase 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57562687/