spring-bootliquibaseliquibase-hibernate

Liquibase error After migrating from spring boot 2.2.7 to 3.2.4


I recently migrated my project from Spring Boot 2.2.7 to 3.2.4 and started encountering several Liquibase errors Caused by: liquibase.exception.LiquibaseException: Error parsing db/changelog/RC-101/002_create_entitlement_user_table.yml : Error parsing db/changelog/RC-101/002_create_entitlement_user_table.yml: Unknown change type 'changeSet'. Check for spelling or capitalization errors and missing extensions such as liquibase-commercial.

My change set is

databaseChangeLog:
  - changeSet:
      id: '2'
      author: Jhon Doe
      preConditions:
        - onFail: MARK_RAN
        - not:
            - tableExists:
                tableName: dummy_table
      changes:
        - createTable:
            tableName: dummy_user
            columns:
              - column:
                  name: dummy_id
                  type: varchar(100)
                  constraints:
                    primaryKey: true
              - column:
                  name: site_id
                  type: bigint
              - column:
                  name: user_id
                  type: bigint
                  constraints:
                    primaryKey: true
              - column:
                  name: creation_date
                  type: TIMESTAMP
                  constraints:
                    nullable: false
              - column:
                  name: last_modification_date
                  type: TIMESTAMP
                  constraints:
                    nullable: false
              - column:
                  name: created_by
                  type: varchar(255)
                  constraints:
                    nullable: false
              - column:
                  name: last_modified_by
                  type: varchar(255)
                  constraints:
                    nullable: false
        - changeSet:
            id: '3'
            author: Jhon Boy
            changes:
              - addForeignKeyConstraint:
                  constraintName: fk_dummmy
                  baseTableName: dummy_user
                  baseColumnNames: site_id
                  referencedTableName: site
                  referencedColumnNames: id
                  validate: true
        - changeSet:
            id: '4'
            author: Luffy
            changes:
              - addForeignKeyConstraint:
                  constraintName: fk_dummy_user_s
                  baseTableName: dummy_user
                  baseColumnNames: user_id
                  referencedTableName: user
                  referencedColumnNames: id
                  validate: true

This change set was working fine in Spring Boot 2.2.7. Is this issue related to Liquibase or due to the Hibernate version upgrade? Is there any changelog documentation that I can refer to for resolving this issue?

Additional Information:

Spring Boot version: 3.2.4 Liquibase version: 4.24.0 Hibernate ORM version: 6.4.4.FINAL Hibernate Validator version: 8.0.1.FINAL Any help or pointers would be greatly appreciated!


Solution

  • Not sure how or why that changelog worked before because all changesets after id=2:author=Jhon Doe are nested below it. That's an invalid configuration since indention/whitespace are meaningful in YAML. Liquibase probably fixed the YAML parser to better adhere to those conventions. Try this changelog:

    databaseChangeLog:
      - changeSet:
          id: '2'
          author: Jhon Doe
          preConditions:
            - onFail: MARK_RAN
            - not:
                - tableExists:
                    tableName: dummy_table
          changes:
            - createTable:
                tableName: dummy_user
                columns:
                  - column:
                      name: dummy_id
                      type: varchar(100)
                      constraints:
                        primaryKey: true
                  - column:
                      name: site_id
                      type: bigint
                  - column:
                      name: user_id
                      type: bigint
                      constraints:
                        primaryKey: true
                  - column:
                      name: creation_date
                      type: TIMESTAMP
                      constraints:
                        nullable: false
                  - column:
                      name: last_modification_date
                      type: TIMESTAMP
                      constraints:
                        nullable: false
                  - column:
                      name: created_by
                      type: varchar(255)
                      constraints:
                        nullable: false
                  - column:
                      name: last_modified_by
                      type: varchar(255)
                      constraints:
                        nullable: false
      - changeSet:
          id: '3'
          author: Jhon Boy
          changes:
            - addForeignKeyConstraint:
                constraintName: fk_dummmy
                baseTableName: dummy_user
                baseColumnNames: site_id
                referencedTableName: site
                referencedColumnNames: id
                validate: true
      - changeSet:
          id: '4'
          author: Luffy
          changes:
            - addForeignKeyConstraint:
                constraintName: fk_dummy_user_s
                baseTableName: dummy_user
                baseColumnNames: user_id
                referencedTableName: user
                referencedColumnNames: id
                validate: true