在 liquibase 中插入变更集不起作用
Insert changeset in liquibase does not work
我开始在我的 spring 引导代码中集成 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)
当应用程序顺利启动时,我遇到了一个 st运行ge 行为,即只有序列创建成功但在我的架构中没有 table 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)
我开始在我的 spring 引导代码中集成 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)
当应用程序顺利启动时,我遇到了一个 st运行ge 行为,即只有序列创建成功但在我的架构中没有 table 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)