处理不断变化的MySQL模式需求的策略? [英] Strategies for dealing with constantly changing requirements for MySQL schemas?

查看:76
本文介绍了处理不断变化的MySQL模式需求的策略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个非常早期的项目中使用Hibernate EntityManager和Hibernate Annotations for ORM。该项目需要尽快启动,但规格不断变化,我担心系统将启动并收集实时数据,然后规格将再次发生变化,并且我将处于需要更改数据库模式。



我如何设置以最小化这种影响?是否有任何处理这种迁移的开源项目? Hibernate可以自动执行此操作(不擦除数据库)吗?



您的建议非常感谢。

解决方案

这是一个功能性或组织性问题,而不是技术问题。没有工具会自动猜测如何将数据从一个模式迁移到另一个模式。您最好学习如何编写存储过程以迁移数据。

您可能需要禁用约束,创建临时表和列,复制大量数据,然后删除临时表和列并重新启用约束迁移您的数据。

进入维护模式后,每个修改架构的新功能都应该附带该脚本,以允许从当前架构和生产中的数据迁移到新的。


I'm using Hibernate EntityManager and Hibernate Annotations for ORM in a very early stage project. The project needs to launch soon, but the specs are changing constantly and I am concerned that the system will be launched and live data will be collected, and then the specs will change again and I will be in a situation where I need to change the database schema.

How can I set things up in order to minimize the impact of this? Are there any open source projects that deal with this kind of migration? Can Hibernate do this automatically (without wiping the database)?

Your advice is much appreciated.

解决方案

It's more a functional or organizational problem than a technical one. No tool will automatically guess how to migrate data from one schema to another one. You'd better learn how to write stored procedure in order to migrate your data.

You'll probably need to disable constraints, create temporary table and columns, copy lots of data, and then delete the temporary tables and columns and re-enable constraints to have migrate your data.

Once in maintenance mode, every new feature that modifies the schema should also come with the script allowing to migrate from the current schema and data in production to the new one.

这篇关于处理不断变化的MySQL模式需求的策略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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