【发布时间】:2014-06-10 11:12:52
【问题描述】:
我正在尝试将一个已经存在的 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。
【问题讨论】:
-
你可以使加速为空吗?如果你能做到这一点,添加下一个代码可能是解决方案:静态约束= {加速可空:真}
-
我确实试过这个,但我仍然得到同样的错误。
标签: grails sql-server-2012 grails-orm grails-domain-class grails-2.3