如何升级用ORM工具构建的数据库模式? [英] How to upgrade database schema built with an ORM tool?

查看:126
本文介绍了如何升级用ORM工具构建的数据库模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个通用的解决方案来升级数据库模式与ORM工具,如JPOX或Hibernate。

I'm looking for a general solution for upgrading database schema with ORM tools, like JPOX or Hibernate. How do you do it in your projects?

我想到的第一个解决方案是创建我自己的升级数据库的机制,SQL脚本会执行所有的工作。但在这种情况下,我必须记住每次更新对象映射时创建新脚本。我仍然必须处理低级SQL查询,而不是只定义映射,并允许ORM工具来做所有的工作...

The first solution that comes to my mind is to create my own mechanism for upgrading databases, with SQL scripts doing all the work. But in this case I'll have to remember about creating new scripts every time the object mappings are updated. And I'll still have to deal with low-level SQL queries, instead of just defining mappings and allowing the ORM tools to do all the job...

所以问题是如何正确做到。也许一些工具允许简化这个任务(例如,我听说Rails有这样的机制内置),如果是这样,请帮助我决定哪个ORM工具为我的下一个Java项目选择。

So the question is how to do it properly. Maybe some tools allow for simplifying this task (for example, I heard that Rails have such mechanism built-in), if so please help me decide which ORM tool to choose for my next Java project.

推荐答案

LiquiBase 是一个有趣的开源库,用于处理数据库重构(升级)。我没有使用它,但肯定会试试我的下一个项目,我需要升级一个数据库模式。

LiquiBase is an interesting open source library for handling database refactorings (upgrades). I have not used it, but will definitely give it a try on my next project where I need to upgrade a db schema.

这篇关于如何升级用ORM工具构建的数据库模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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