生产数据迁移模式在连续交付 [英] production data migration patterns in continuous delivery

查看:227
本文介绍了生产数据迁移模式在连续交付的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在持续交付中,关系数据库(和模式)迁移模式是什么?

What are relational database (and schema) migration patterns on production in continuous delivery?

在许多传统开发中,DBA安排了一个大迁移脚本在当前发布周期中创建的脚本。但在CD中,开发人员可能希望将更改推送到生产环境,而不是等待使用其他脚本编译它们。

In many traditional developments the DBA arranges a big migration script out of the many smaller scripts created in the current release cycle. But in CD the developer may want to push the change now to production, not wait to compile them with other scripts.

我知道在rails-迁移,更合理地使用原始sql脚本。

I know on rails-migration but to me it looks more reasonable to use raw sql scripts.

我还看到了一些工具,如飞行管理迁移,但我没有读过很多人在生产中使用它们。这是为什么我不知道这里的常见做法。

I've also seen tools like flyway to manage migrations but I have not read of many people using them in production. This is why I wonder what are the common practices here.

推荐答案

Flyway非常适合连续交付/部署。许多客户在所有环境中使用它,包括生产。

Flyway works great for continuous delivery/deployment. Many clients use it across all environments, including production.

跨环境的级联数据库迁移最重要的一点是具有3个步骤的过程:

The single most important thing for cascading DB migrations across environments is to have a 3 step process:

步骤1

旧应用程式程式码与旧资料库一起使用。

Old application code works together with old DB.

第2步

部署新的应用程序代码,并在启动时迁移数据库。此迁移必须向后兼容,以便旧的应用程序代码仍然与新的DB一起使用。这是必要的,因为:

New application code get deployed, and migrates DB on startup. This migration must be backwards-compatible so that old application code still works with the new DB. This is essential because:


  • 然后,您可以进行滚动升级,一次升级一个节点,直到所有节点都有新的应用程序代码<

此步骤可能涉及兼容性视图和触发器来完成此工作。

This step may involve compatibility views and triggers to do the job.

步骤3

已经被证明工作,下一个版本的应用程序代码获得
部署以及必要的数据库迁移以丢弃任何剩余的过时(从步骤1)和兼容性(从步骤2)结构。

After the changes have been proven to work, the next version of the application code gets deployed together with the necessary DB migrations to discard any remaining outdated (from step 1) and compatibility (from step 2) structures.

这篇关于生产数据迁移模式在连续交付的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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