开始填充Grails数据库后端的最佳策略 [英] Best strategy to initially populate a Grails database backend

查看:93
本文介绍了开始填充Grails数据库后端的最佳策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道您的方法/经验,以便最初填充可保存您的应用数据的Grails数据库。假设你有CSV数据,创建一个脚本(使用适合你的任何工具)是更安全:
$ b $ 1.使用域生成Bootstrap命令类,在测试或开发环境中运行它,然后使用本地数据库命令将其导出为prod?


$ b 2.创建数据库的插入脚本,假设GORM的版本= 0并手动递增即将自动生成的ID?



我担心的是,第二种方法可能会导致hibernate的不一致性将有ID生成的责任和那里可能是我缺少的其他东西。



预先致谢。

解决方案

最后,似乎最简单的解决方案是考虑到当前版本(1.2)中的GORM对所有自动生成的ID使用单个序列。因此,在创建您需要的任何脚本(以您的偏好语言)时,考虑到这一点就足够了。我知道1.3版本计划每个表都有自己的序列。


I'd like to know your approach/experiences when it's time to initially populate the Grails DB that will hold your app data. Assuming you have CSVs with data, is is "safer" to create a script (with whatever tool fits you) that:

1.-Generates the Bootstrap commands with the domain classes, run it in test or dev environment and then use the native db commands to export it to prod?

2.-Create the DB's insert script assuming GORM's version = 0 and incrementing manually the soon-to-be autogenerated IDs ?

My fear is that the second approach may lead to inconsistencies for hibernate will have the responsability for the IDs generation and there may be something else I'm missing.

Thanks in advance.

解决方案

Finally it seems that the simplest solution is to consider that GORM as of the current release (1.2) uses a single sequence for all auto-generated ids. So considering this when creating whatever scripts you need (in the language of your preference) should suffice. I understand it's planned for 1.3 release that every table has its own sequence.

这篇关于开始填充Grails数据库后端的最佳策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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