在liquibase中插入变更集不起作用

问题描述

我开始在我的春季启动代码中集成liquibase脚本。现在我只有2个changeSets,我的liquibase脚本如下:

databaseChangeLog:
- changeSet:
    id: liquibase-create-1
    author: liquibase
    preConditions:
      onFail: MARK_RAN
      not:
        sequenceExists:
          sequenceName: APP_USER_SEQ
    changes:
    - createSequence:
         sequenceName: APP_USER_SEQ
         startValue: 1
         minValue: 1
         incrementBy: 1

- changeSet: 
    id: liquibase-create-2
    author: liquibase
    preCondition:
      onFail: MARK_RAN
      not:
        tableExists: 
          tableName: APP_USER
    changes:
    -createTable: 
        tableName: APP_USER
        columns:
          - column:
            name: ID
            constraints:
              primaryKey: true
              nullable: false
              primaryKeyName: APP_USER_PK
            type: INTEGER
          - column:
            name: VERSION
            type: INTEGER
          - column:
            name: USER_ID
            constraints:
              nullable: false
            type: VARCHAR(50)
          - column:
            name: USER_TYPE
            constraints:
              nullable: false
            type: INTEGER
          - column:
            name: PASSWORD
            constraints:
              nullable: false
            type: VARCHAR(50)
          - column:
            name: FirsT_NM
            constraints:
              nullable: false
            type: VARCHAR(50)
          - column:
            name: LAST_NM
            constraints:
              nullable: false
            type: VARCHAR(50)
          - column:
            name: disPLAY_NM
            constraints:
              nullable: false
            type: VARCHAR(50)
          - column:
            name: DEPARTMENT
            constraints:
              nullable: false
            type: VARCHAR(50)
          - column:
            name: EMAIL_ID
            constraints:
              nullable: false
            type: VARCHAR(50)
          - column:
            name: PHONE_NO
            constraints:
              nullable: false
            type: VARCHAR(50)
          - column:
            name: LOCATION
            constraints:
              nullable: false
            type: VARCHAR(50)              

当应用程序顺利启动时,我遇到了一个奇怪的行为,即仅成功创建了序列,但是我的模式中没有表app_user。 日志也支持我的观察:

2020-09-09 23:09:57.992  INFO 6680 --- [           main] liquibase    
: classpath:/db/changelog/db.changelog-master.yaml:
db/changelog/changes/db.changelog-create-v1.yml::liquibase-create-1::liquibase:
Sequence APP_USER_SEQ created 2020-09-09 23:09:57.993  INFO 6680 --- [
main] liquibase                                :
classpath:/db/changelog/db.changelog-master.yaml:
db/changelog/changes/db.changelog-create-v1.yml::liquibase-create-1::liquibase:
ChangeSet
db/changelog/changes/db.changelog-create-v1.yml::liquibase-create-1::liquibase
ran successfully in 36ms 2020-09-09 23:09:58.020  INFO 6680 --- [     
main] liquibase                                :
classpath:/db/changelog/db.changelog-master.yaml:
db/changelog/changes/db.changelog-create-v1.yml::liquibase-create-2::liquibase:
ChangeSet
db/changelog/changes/db.changelog-create-v1.yml::liquibase-create-2::liquibase
ran successfully in 0ms

准确地说,它说 liquibase-create-2在0毫秒内成功运行

任何人都可以解决可能出现的问题吗?

解决方法

是缩进问题。可以正常工作:

- changeSet: 
    id: liquibase-create-2
    author: liquibase
    preCondition:
      onFail: MARK_RAN
      not:
        tableExists: 
          tableName: APP_USER
    changes:
    - createTable: 
        tableName: APP_USER
        columns:
          - column:
              name: ID
              constraints:
                primaryKey: true
                nullable: false
                primaryKeyName: APP_USER_PK
              type: INTEGER
          - column:
              name: VERSION
              type: INTEGER
          - column:
              name: USER_ID
              constraints:
                nullable: false
              type: VARCHAR(50)
          - column:
              name: USER_TYPE
              constraints:
                nullable: false
              type: INTEGER
          - column:
              name: PASSWORD
              constraints:
                nullable: false
              type: VARCHAR(50)
          - column:
              name: FIRST_NM
              constraints:
                nullable: false
              type: VARCHAR(50)
          - column:
              name: LAST_NM
              constraints:
                nullable: false
              type: VARCHAR(50)
          - column:
              name: DISPLAY_NM
              constraints:
                nullable: false
              type: VARCHAR(50)
          - column:
              name: DEPARTMENT
              constraints:
                nullable: false
              type: VARCHAR(50)
          - column:
              name: EMAIL_ID
              constraints:
                nullable: false
              type: VARCHAR(50)
          - column:
              name: PHONE_NO
              constraints:
                nullable: false
              type: VARCHAR(50)
          - column:
              name: LOCATION
              constraints:
                nullable: false
              type: VARCHAR(50)