顧客向けのドメイン クラスがあります。請求先住所と配送先住所を収集していたのに、郵便番号の値が 1 つしか記録されていなかったため、最近ドメイン クラスに変更する必要がありました。だから私はなんて簡単な修正だと思った。zipcode を billzipcode に変更し、shipzipcode の新しいフィールドを作成します。dbm-gorm-diff を実行して変更ログを作成し、次に dbm-update を実行して行った変更を実行しました。この時点までのすべてがスムーズに機能します。しかし、アプリをデバッグして、データソースへの変更が問題ないことを確認します。ただし、新しい顧客レコードを保存しようとすると、次のエラーが発生します。
NULL not allowed for column "ZIPCODE"; SQL statement:
insert into customer (id, version, billaddr, billcity, billstate, billzipcode, cell, contact, country_id, custcode, custname, date_created, email, fax, last_updated, organization, phone, shipaddr, shipasbill, shipcity, shipstate, shipzipcode, status, tenant_id) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [23502-164]. Stacktrace follows:
org.h2.jdbc.JdbcSQLException: NULL not allowed for column "ZIPCODE"; SQL statement:
insert into customer (id, version, billaddr, billcity, billstate, billzipcode, cell, contact, country_id, custcode, custname, date_created, email, fax, last_updated, organization, phone, shipaddr, shipasbill, shipcity, shipstate, shipzipcode, status, tenant_id) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [23502-164]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.table.Column.validateConvertUpdateSequence(Column.java:293)
at org.h2.table.Table.validateConvertUpdateSequence(Table.java:680)
at org.h2.command.dml.Insert.insertRows(Insert.java:120)
at org.h2.command.dml.Insert.update(Insert.java:84)
at org.h2.command.CommandContainer.update(CommandContainer.java:73)
at org.h2.command.Command.executeUpdate(Command.java:226)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:143)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:129)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at com.companyName.appname.billing.CustomerController$_closure6.doCall(CustomerController.groovy:45)
at grails.plugin.multitenant.core.servlet.CurrentTenantServletFilter.doFilter(CurrentTenantServletFilter.java:53)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
ZIPCODE 列がドメイン クラスになくなってしまったので、途方に暮れています。任意のガイダンスをいただければ幸いです。
編集: リクエストごとに、移行プラグインによって生成された変更は次のとおりです。
changeSet(author: "user (generated)", id: "1363806498118-1") {
dropColumn(tableName: "admission", columnName: "pen")
addColumn(tableName: "admission") {
column(name:"pen_id", type:"bigint")
}
}
changeSet(author: "user (generated)", id: "1363806498118-2") {
addColumn(tableName: "customer") {
column(name: "billzipcode", type: "varchar(50)") {
constraints(nullable: "false")
}
}
}
changeSet(author: "user (generated)", id: "1363806498118-3") {
addColumn(tableName: "customer") {
column(name: "shipzipcode", type: "varchar(50)") {
constraints(nullable: "false")
}
}
}
changeSet(author: "user (generated)", id: "1363806498118-4") {
addColumn(tableName: "customer_costs") {
column(name: "subtotal", type: "float(19)") {
constraints(nullable: "false")
}
}
}
changeSet(author: "user (generated)", id: "1363806498118-5") {
addForeignKeyConstraint(baseColumnNames: "pen_id", baseTableName: "admission", constraintName: "FK1A21809D0C6EF15", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "pen", referencesUniqueColumn: "false")
}
changeSet(author: "user (generated)", id: "1363806498118-6") {
dropColumn(columnName: "zipcode", tableName: "customer")
}