寻找数据库版本控制的解决方案

编程入门 行业动态 更新时间:2024-10-21 13:34:35
本文介绍了寻找数据库版本控制的解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

问题描述:

在我们的项目中,我们有一个生产数据库"和许多开发人员".我们想知道如何管理和安装更改.我们已经有了一些程序,但需要很多时间,有时会导致错误.

In our project we have one "production database" and many "devs". We want to know how we can manage and install the changes. We already have some procedures but it takes a lot of time and sometimes causes errors.

我们不能丢失数据 - 所以我们不能使用删除表".我们只能使用alter table".

We can't lose data - so we can't use "drop table". We can only use "alter table".

我们实际的数据库版本控制程序"是这样的:

Our actual "db versioning procedure" is like this:

  • 我们有一个名为 [actual_version] 的表,其中包含已安装数据库架构的实际版本
  • 我们有一个名为changes_script.sql"的文件,其中包含所有数据库更改 - 该文件存储在 SVN 上

当开发人员想要在 SVN 上提交新修订时,他需要通过添加更改_script.sql一个块:

When a developer wants to commit a new revision on SVN he needs to change_script.sql by adding a block:

if ([acctual_version].version < "23")) { --- sql script ---- updateVersionTo("23") end if

当我们想要升级数据库架构时,我们只需执行"change_scripts.sql

When we want to upgrade the database schema we just "execute" the change_scripts.sql

有人有更好的主意吗?

推荐答案

Red Gate 的 Sql Compare 工具可以比较两个表(或两个 DDL 脚本集合,或一组脚本到一个表等)并为您生成迁移脚本.

Red Gate's Sql Compare tool can compare two tables (or two collections of DDL scripts, or one set of scripts to a table, etc) and generate the migration script for you.

如果您使用 Ruby,您可以查看Ruby 迁移",这是一种在代码中进行数据库版本控制的正式方式.(.NET 中有类似的东西,例如 RikMigrations 和 Fluent Migrator,我相信其他平台也存在类似的东西).

If you're working in Ruby you can look into "Ruby Migrations", which is a formalized way of doing DB versioning in code. (There are similar things in .NET such as RikMigrations and Fluent Migrator, and I'm sure similar things exist for other platforms as well).

正如 Randy Minder 所说,您也可以使用 VS DB 版本为您管理架构,尽管我认为 RedGate 工具工作起来同样简单,并且不会将您绑定到特定平台或 IDE.

As Randy Minder said, you can also use VS DB Edition to manage your schema for you, although I think the RedGate tools work just as easily and don't tie you to a specific platform or IDE.

更多推荐

寻找数据库版本控制的解决方案

本文发布于:2023-10-30 04:26:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541761.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决方案   版本   数据库

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!