我正在尝试将现有的 PHP 应用程序移动到 grails 中。
我已经根据现有数据库创建了域,并且代码运行良好。
当我需要在我的域中添加一个额外的布尔字段时,就会出现问题。
我收到以下错误。
2014-06-10 16:24:54,146 [localhost-startStop-1] ERROR hbm2ddl.SchemaUpdate - Unsuccessful: alter table entry add expedite tinyint not null
Error |
2014-06-10 16:24:54,163 [localhost-startStop-1] ERROR hbm2ddl.SchemaUpdate - ALTER TABLE only allows columns to be added that can contain nulls, or have a DEFAULT definition specified, or the column being added is an identity or timestamp column, or alternatively if none of the previous conditions are satisfied the table must be empty to allow addition of this column. Column 'expedite' cannot be added to non-empty table 'entry' because it does not satisfy these conditions.
我试图在变量本身中指定默认值。
boolean expedite = false
我还尝试在静态映射中添加默认值,如下所示:
static mapping = {
table 'entry'
expedite defaultValue: false
version false
}
但是错误仍然出现。知道我哪里出错了吗?我正在使用 sql server 2012。