如何在Grails中修改域类? [英] How do you modify a Domain Class in Grails?

查看:101
本文介绍了如何在Grails中修改域类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法想象在自动创建相应的数据库表之后如何修改域类的标准做法。

I can't figure how what the "standard practice" is for modifying a Domain Class after it has automatically created the corresponding database table.

没有迁移在Grails,没有办法,我可以找到告诉它输出它将生成的新SQL,所以你可以将其与上一个表定义,并手动发出自己的ALTER TABLE命令(这是我在django)。

There's no "migration" in Grails, and there's no way that I can find to tell it to output the new SQL it would generate so you can compare it to the previous table definition and manually issue your own ALTER TABLE command (that's what I do in django).

我刚刚得到了书Grails的绝对指南,它没有提到这个主题,我在Grails网站上找不到任何东西。

I just got the book "The Definitive Guide to Grails" and it is silent on the subject, and I can't find anything on the Grails website.

推荐答案

这是grails的弱点,我不知道一个好的办法来处理它。我做的是创建修改的域类的副本,然后将修改的域类的表的SQL模式与域类的副本生成的SQL模式进行比较。然后你必须手动使原始表所需的任何改动。我发现诸如关系之类的东西在域类的时候会发生改变,但是添加一个约束来强制字段成为一个文本类型并不总是会改变.......

This is a weak point of grails and I don't know a good way to deal with it. What I do is create a copy of the modified domain class, then compare the SQL schema of the table of the modified domain class to that generated by the copy of the domain class. Then you have to manually make what ever alterations are necessary to your original table. I've found that things such as relationships tend to change when the domain class does, but things such as adding a constraint to force a field to be a text type don't always get changed.......

这篇关于如何在Grails中修改域类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆