Ste*_*bbi 2 java database hibernate liquibase
liquibase 新手。我有一个由 hibernate 管理的现有架构。我现在需要删除一些表,并且我正在使用 liquibase。我编写了一个成功删除表的配置。
但我希望仅当表存在时才运行检查,因为新安装的系统不会有该表,因为休眠映射对象不再存在。
我试图添加一个前提条件。但是,我的日志仍然表明 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
Run Code Online (Sandbox Code Playgroud)
日志中的错误:表 public.some_old_table 不存在...
PreconditionFailedException
Run Code Online (Sandbox Code Playgroud)
这就像我正在检查先决条件……但仍然没有通过。
也尝试过
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
Run Code Online (Sandbox Code Playgroud)
问题在于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
Run Code Online (Sandbox Code Playgroud)