在 liquibase 脚本中使列不可为空

Make column non-nullable in liquibase script

在我的 liquibase 脚本中,我在第一个更改集中犯了一个错误,我的主键中的一个列 (OWNER) 可以为 null,因为我忘记为其设置 nullable 为 false,如下所示

  <changeSet author="sharakab" id="ALERT_WF:CREATE">
        <createTable catalogName="${rec_owner}" tableName="ALERT_WF" tablespace="${table_space_rec_data}">
            <column name="ALERT_ID" type="VARCHAR2(150 CHAR)">
                <constraints nullable="false" />
            </column>
            <column name="STATUS" type="VARCHAR2(30 CHAR)">
                <constraints nullable="false" />
            </column>
            <column name="STATUS_CHANGE_DATE" type="TIMESTAMP(6)">
                <constraints nullable="false" />
            </column>
            <column name="OWNER" type="VARCHAR2(200 CHAR)"/>
            <column name="VERSION" type="NUMBER(2,0)" defaultValue='1'>
                <constraints nullable="false" />
            </column>
            <column name="LAST_ACTIONED_BY" type="VARCHAR2(200 CHAR)"/> 
            <column name="REVIEWER_GRP_DISP_ID" type="VARCHAR2(20 CHAR)">
                <constraints nullable="false" />
            </column>
            <column name="REVIEWER_GRP_NAME" type="VARCHAR2(50 CHAR)"/>
            <column name="RECORD_CREATION_DATE" type="TIMESTAMP(6)"/>
        </createTable>

        <addPrimaryKey catalogName="${rec_owner}" columnNames="ALERT_ID,STATUS,VERSION,STATUS_CHANGE_DATE,OWNER,REVIEWER_GRP_DISP_ID" constraintName="PK_ALERT_WF"
                       tableName="ALERT_WF" tablespace="${table_space_rec_index}"/>
    </changeSet>

当我 mvn clean install 我的 springboot 应用程序时,出现以下错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibas
e.exception.MigrationFailedException: Migration failed for change set classpath:/sql/tables/ALERT_WF.xml::ALERT_WF:CREATE::sharakab:
     Reason: liquibase.exception.DatabaseException: Column "OWNER" must not be nullable; SQL statement:
ALTER TABLE PUBLIC.ALERT_WF ADD CONSTRAINT PK_ALERT_WF PRIMARY KEY (ALERT_ID, STATUS, VERSION, STATUS_CHANGE_DATE, OWNER, REVIEWER_GRP_DISP_ID) [90023-200] [Failed SQL: (90023) ALTER TABLE PUBLIC.ALERT_WF ADD CONSTRAINT PK_ALERT_WF PRIMARY KEY (ALERT_ID, STATUS, VERSION, STATUS_CHANGE_DATE, OWNER, R
EVIEWER_GRP_DISP_ID)]

我尝试在 chnageset 下方添加但它不起作用并且仍然给出相同的错误:

在我试图将 nullable 设置为 false 的行下进行一些更改

<changeSet id="ALERT_WF::add_non_null_constraint" author="sharakab">
        <addNotNullConstraint catalogName="${rec_owner}" columnDataType="VARCHAR2(200 CHAR)" columnName="OWNER" tableName="ALERT_WF" />         
</changeSet>

谁能告诉我如何改正这里的错误。

添加此更改集。确保更改 changeSet id。

<changeSet id="ALERT_WF::add_non_null_constraint" author="sharakab">
    <addPrimaryKey tableName="ALERT_WF" columnNames="OWNER"/>
</changeSet>