Yaml liqubase backgrounds

Is it possible to use Precondition in YAML, I did not find any sources except this page http://www.liquibase.org/documentation/yaml_format.html

But I'm looking for an equivalent:

<changeSet id="addColumn-example">
  <preConditions onFail="MARK_RAN">
     <columnExists schemaName="earls" 
           tableName="category" columnName="display_name"/>
  </preConditions>
  <dropColumn columnName="display_name" schemaName="earls" tableName="category"/>
</changeSet>  

So my natural translation would be:

changeSet:
  id: addColumn-example
  author: francis
  preConditions:
    - columnExist:
      schemaName: earls
      tableName: category
      columnName: display_name                    
  changes:
    - addColumn:
      columns:
        - column:
          name: display_name
          type: varchar(100)

But I miss onFail ...

+4
source share
3 answers

this topic is poorly documented, but after many attempts ... you can write something like this:

databaseChangeLog:
  - changeSet:
      id: 1
      author: pazfernando
      preConditions:
        - onFail: MARK_RAN
        - tableExists:
            schemaName: sa
            tableName: PROVEEDORBIENSERVICIO
      changes:
        - renameTable:
            newTableName: PROVEEDORBIENSERVICIO
            oldTableName: PROVEEDORSERVICIO
            schemaName: sa

Hope this helps ... bye

+5
source

The following seems to work:

databaseChangeLog:
  - changeSet:
      id: 1
      author: mraible
      preConditions:
        onFail: MARK_RAN
        not:
          sequenceExists:
            schemaName: public
            sequenceName: hibernate_sequence
      changes:
      - createSequence:
          sequenceName: hibernate_sequence
+1
source

Perhaps something that does not work with Liquibase 3.1.x, but should only work in version 3.2.0. Your changeSet example should be correct.

0
source

Source: https://habr.com/ru/post/1542386/


All Articles