首页 > 解决方案 > 为什么我不能在具有默认值的 notNull 列中插入空值?

问题描述

我使用 liquibase yml 在表中添加了一个新列:

databaseChangeLog:
  - changeSet:
      id: pay-process-add-column
      author: m.rybalkin
      changes:
        - addColumn:
            tableName: pay_process
            columns:
              - column:
                  name: deferred_pay_notification
                  type: boolean
                  defaultValue: false
                  constraints:
                    nullable: false

但是当我尝试deferred_pay_notification = null在表中插入一个新行时,我收到了一个错误:

Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "deferred_pay_notification" violates not-null constraint

可以修复吗?

标签: postgresqlliquibase

解决方案


推荐阅读