Insert rows using Liquibase in yaml format

I am trying to define a changeSet to insert two rows into a table using Liquibase. For this, I wrote the following changeSet:

- changeSet:
  id: 1.0/7
  author: stivlo
  changes:
    -insert:
        tableName: my_table
        columns:
        - column:
            name: id
            value: "1"
        - column:
            name: name
            value: "One"
    -insert:
        tableName: my_table
        columns:
        - column:
            name: id
            value: "2"
        - column:
            name: name
            value: "Two"

When I launch the Spring boot application, a set of changes is executed, but no rows are inserted.

In the DATABASECHANGELOG table, I find a rude saying that the migration is complete, but the description is "Empty", which means that Liquibase does not see the changes in the migration.

How can I fix my barley to be able to insert these two lines?


PS I was able to solve my problem by inserting SQL expressions, rather than using Liquibase inserts.

- changeSet:
  id: 1.0/7
  author: stivlo
  changes:
    - sql:
        sql: insert into my_table (id, name) values (1, "One")
    - sql:
        sql: insert into my_table (id, name) values (2, "Two")

This works, but I'm still curious to know how to correctly determine the lipibase insert. Thank.

+4
source share
2

,

Liquibase "updateSQL", , SQL.

+1

, .
, - , .yml, stackoverflow. :

- changeSet:
    id: 1.0/7
    author: stivlo
    comment: "Some comments go here"
    changes:
     - insert:
         tableName: my_table
         columns:
         - column:
             name: id
             value: "1"
         - column:
             name: name
             value: "One"
     - insert:
         tableName: my_table
         columns:
         - column:
             name: id
             value: "2"
         - column:
             name: name
             value: "Two"

, - changeSet
, - , ,
Btw , databaseChangeLog ?

- , Liquibase:

( )

-, Mattias B, "updateSQL". CLI,

  java -jar liquibase.jar --driver=org.h2.Driver --classpath=h2-1.3.170.jar --changeLogFile=yourchangelogpath/changelog.yaml --url=jdbc:h2:D:/Variaciok/db/variation --username=sa --password= updateSQL

,

driver: org.h2.Driver
classpath: h2-1.3.170.jar
changeLogFile: yourchangelogpath/changelog.yaml
url: jdbc:h2:D:/db/variation
username: sa
password:

java -jar liquibase.jar --defaultsFile=our_database.properties updateSQL

liquibase.properties, --defaultsFile,

java -jar liquibase.jar updateSQL

-, , CLI, .yml

, !

+1

All Articles