如何将对生产数据库所做的架构更改合并到我的迁移管理流程中?

发布于 2024-07-17 12:53:44 字数 326 浏览 5 评论 0 原文

我的团队正在评估用于管理数据库迁移的 dbdeploy。 据我了解,使用迁移需要一些流程规则,即为每个更改编写迁移,并且为了达到生产,必须将其从本地提升到开发、测试到生产。

有时,我们的生产 DBA 团队会直接对生产环境进行架构更改。 如果我们编写一个新的迁移来针对数据库的当前开发版本进行更改,则在将迁移部署到生产之前,该迁移将永远不会针对已包含更改的模式进行测试。 这让我很担心。

另一种选择是直接对基线模式进行更改,然后在所有环境(本地、开发、测试、阶段)中重建数据库。 我担心这种方法,因为新架构可能会导致一个或多个迁移中断。

人们目前如何处理这种情况?

My team is evaluating dbdeploy for managing database migrations. As I understand it, using migrations requires a bit of process discipline, namely that a migration is written for every change, and that to reach production, it would have to be promoted from local to development to test to production.

Occasionally our production DBA team makes schema changes directly to the production environment. If we write a new migration to make the change against our current development version of the database, that migration will never be tested against a schema that already contains the change until the migration is being deployed to production. This concerns me.

The other option is to make the change directly to the baseline schema, then rebuild the database in all environments (local, development, test, stage). This approach concerns me, because the new schema could cause one or more migrations to break.

How are people currently handling this scenario?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

想念有你 2024-07-24 12:53:44

我们连夜将生产数据库的副本恢复到测试服务器上。

然后,它可以:

  • 作为参考副本(代码和数据)
  • 我们可以重置我们所做的任何更改
  • 我们可以根据真实数据进行测试
  • 我们可以并排新/旧代码性能
  • 我们可以生成 100% 安全的更改/回滚脚本(红色Gate)

我们不会重建开发/测试数据库等,但我们的一些其他项目会重建。 但是,我不确定这样做的好处,因为数据库不是模式和代码:它也是数据。 它与编译的 .net 应用程序不同。

在我的商店中,未经批准而对产品数据库进行更改(任何更改)的生产 DBA 将被解雇。 这已经发生了。

We restore a copy of our production DB onto a test server overnight.

This then serves:

  • As a reference copy (code and data)
  • We can reset any changes we've made
  • We can test against real data
  • We can side by side new/old code preformance
  • We can generate 100% safe change/rollback scripts (Red Gate)

We don't rebuild dev/test databases etc but some of our fellow projects do. However, I'm not sure of the benefit because a database is not schema and code: it's data too. It's different to a complied .net app.

In my shop, a production DBA making changes to a prod DB (any change at all) without approval would be fired. And it's happened.

一杯敬自由 2024-07-24 12:53:44

生产模式上的数据库更改必须不时发生,这是可以理解的。 但非常重要的是,必须将这些记录下来并尽快传达给开发团队。 执行 SQL 的纯文本以及对受影响的用例/功能和可能的错误跟踪问题的注释可以

时不时地将实时数据库取回到开发中,并将其(它的模式)与开发人员所拥有的进行比较是一个好主意以及。

It is understandable that DB changes on the production schema have to happen from time to time. It is very important though that these have to be documented and communicated ASAP back to the development team. Plain text with the sql executed together with comments on affected use cases/functionalities and possible bug tracking issues would do

Fetching the live DB back to the development every now and then and comparing it (it's schema) with what the developers have is a good idea as well.

糖粟与秋泊 2024-07-24 12:53:44

我认为 DBA 在生产数据库上唯一可以改变的就是到处添加索引并调整一些存储过程 - 所有这些都是为了性能。 一般来说,对数据库的所有其他更改都会导致数据库架构与应用程序不兼容。

考虑到这一点,唯一真正应该进行版本控制的是存储过程,DBA 有责任将它们签入源代码管理。 索引的波动性更大,实际上可能不包含在迁移脚本中。

I assume that the only thing DBA can change on production DB is to add an index here and there and tweak a few sprocs - all for the sake of performance. All other changes to the DB can, generally speaking, render DB schema to be incompatible with the application.

With this in mind, the only thing that actually should be versioned are sprocs, and it's the responsibility of a DBA to check them into source control. Indexes are much more volatile and may actually not be included in migration scripts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文