Prevent error when dropping not existing sequences, creating existing users

前端 未结 5 901
北荒
北荒 2020-12-20 16:17

I have a bunch of sql scripts that create / drop sequences, users and other objects. I\'m running these scripts through liquibase, but they fail because oracle complains whe

5条回答
  •  旧巷少年郎
    2020-12-20 16:36

    Liquibase has a failOnError attribute you can set to false on changeSets that include a call that could fail.

    
       
    
    

    This allows you to have simple create user, create sequence, drop user, and drop sequence changeSets and if the statement throws an error because they users/sequences exist/don't exist they will still be marked as ran and the update will continue.

    The downside of this approach is that it will also mark them as ran and continue if they error for some other reason (bad permissions, connection failure, invalid SQL, etc.) The more accurate approach is to use preconditions, like this:

    
       
       
    
    

    There is no userExists precondition currently, but you can create custom preconditions or fall back to the precondition. See http://www.liquibase.org/documentation/preconditions.html for documentation

提交回复
热议问题