如果表存在则跳过liquibase更改

编程入门 行业动态 更新时间:2024-10-26 02:31:14
本文介绍了如果表存在则跳过liquibase更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

liquibase的新手.我有一个由休眠管理的现有架构.现在,我需要删除一些表,并且正在使用liquibase.我编写了一个配置,成功删除了表.

New to liquibase. I have an existing schema managed by hibernate. I now need to remove some tables and I'm using liquibase. I wrote a config that succesfully deletes the table.

但是我希望仅在表存在的情况下运行检查,因为系统的新安装将没有该表,因为休眠映射对象不再存在.

But I want the check to run only if the table exists, since a new install of the system would not have the table since the hibernate mapping objects no longer exist.

我试图添加一个前提条件.但是,我的日志仍然表明liquibase正在失败,因为它试图删除该表并且该表不存在.我做错了什么?我正在使用Spring Boot/Java

I attempted to add a precondition. However, my logs still indicating that liquibase is failling becuase it tries to delete the table and it doesn't exist. What am I not doing correctly? I'm using 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不存在 ...

error in log: Table public.some_old_table does not exist ...

PreconditionFailedException

这就像ti正在检查先决条件...仍然无法通过.

It's like ti's checking the preconditions... and still failing them.

也尝试过

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.

The issue was in the on-fail attribute not being spelled correctly. on-fail should be onFail.

正如@Julian所提到的,最好将范围限定为特定变更集的前提作为前提,并且注释应该放在preCondition之后,尽管这不是手头的问题.

As @Julian mentioned, it's best to put a precondition scoped to a specific change set, and the comment should go after a preCondition, although that was not the issue at hand here.

databaseChangeLog: - changeSet: id: zzchange-1.0-remove-xczczxc author: zzzz preConditions: on-fail: mark_ran tableExists: tableName: some_old_table comment: Remove some_old_table table - no longer needed changes: - dropTable: tableName: some_old_table

更多推荐

如果表存在则跳过liquibase更改

本文发布于:2023-10-19 18:14:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1508354.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:跳过   liquibase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!