我刚开始在Maven(3.3.9)和PostgreSQL(9.5.4)的Java(1.8)项目中使用Liquibase(3.5.3)。我不明白为什么以下json changelog文件的第二个变更集没有按预期工作。
{
"databaseChangeLog": [
{
"preConditions": [
{
"dbms": { "type": "postgresql" },
"runningAs": { "username": "postgres" }
}
]
},
{
"changeSet": {
"id": "1",
"author": "fernando.costa",
"changes": [
{
"createTable": {
"tableName": "contact",
"columns": [
{
"column": {
"name": "id",
"type": "bigint",
"autoIncrement": true,
"constraints": {
"primaryKey": true,
"nullable": false
}
}
},
{
"column": {
"name": "first_name",
"type": "varchar(100)",
"constraints": { "nullable": false }
}
}
]
}
}
]
}
},
{
"changeSet": {
"id": "2",
"author": "fernando.costa",
"changes": [
{
"insert": {
"tableName": "contact",
"columns": [
{
"column": {
"name": "first_name",
"value": "George"
}
}
]
}
}
]
}
}
]
}
第一个变更设置没问题,但第二个设置没有执行。它会引发以下错误:
SEVERE 12/9/16 5:30 AM:liquibase:db.changelog.json:db.changelog.json :: 2 :: fernando.costa:Change Set db.changelog.json :: 2 :: fernando。哥斯达黎加失败了错误:执行SQL INSERT INTO联系人时出错(first_name)VALUES(NULL):错误:“first_name”列中的空值违反非空约束 细节:失败的行包含(1,null)。
我做错了什么?我已将first_name
设置为George
,但生成的SQL语句似乎插入了NULL ...
谢谢!