2

I'm new to back-end development and currently trying to add a column to my app_user table. like below.

- changeSet:
      id: 300520202335
      author: Malindu De Alwis
      changes:
        - addColumn:
            tableName: app_user
              columns:
              -column:
                name: address
                type: VARCHAR(255)

It gives this error

Caused by: org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here

in 'reader', line 23, column 22: columns: ^

I use Spring boot and postgre sql. Please try to figureout the issue

Malindu Sandaruwan
  • 1,477
  • 2
  • 13
  • 27

3 Answers3

5

I had the same issue, and I found there were 2 things wrong with the example code given on liquibase.com:

  • "columns" should be at the same indent as "tableName"
  • The whitespace between "-" and "column" mentioned by others

The example should be

changeSet:
  id: addColumn-example
  author: liquibase-docs
  changes:
    - addColumn:
        tableName: person
        columns:
            - column:
                name: middlename
                type: varchar(50)

Somewhat disappointing that the official examples don't compile.

Malthalus
  • 51
  • 2
1

If you look at an example yaml test changelog like the one included here : https://github.com/liquibase/liquibase/blob/master/liquibase-core/src/test/resources/liquibase/parser/core/yaml/testCasesChangeLog.yaml -- you will be able to replicate an addColumn change type in yaml format that works. For example:

    - changeSet:
        id: using after column attribute
        author: cmouttet
        changes:
            - addColumn:
                columns:
                    - column:
                        afterColumn: firstname
                        name: middlename
                        type: varchar(50)
                tableName: person 

I believe @tobhai is correct though -- there is missing whitespace in - column.

Sandeep Kumar
  • 2,397
  • 5
  • 30
  • 37
krisCode
  • 33
  • 4
0

I think the error results from missing whitespace between -column. Have you tried it with - column?

tobhai
  • 412
  • 6
  • 13