验证数据库更改(版本控制) [英] Verify database changes (version-control)

查看:182
本文介绍了验证数据库更改(版本控制)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了很多关于数据库版本控制的重要性的帖子。但是,我找不到一个简单的解决方案如何检查数据库是否处于应该是的状态。

I have read lots of posts about the importance of database version control. However, I could not find a simple solution how to check if database is in state that it should be.

例如,我有一个带有Version表的数据库(版本号存储在那里)。但是数据库可以被开发者访问和编辑,而不改变版本号。如果例如开发人员更新存储过程并且不更新版本数据库状态与版本值不同步。

For example, I have a databases with a table called "Version" (version number is being stored there). But database can be accessed and edited by developers without changing version number. If for example developer updates stored procedure and does not update Version database state is not in sync with version value.

如何跟踪这些更改?我不需要跟踪什么更改,但只需要检查数据库表,视图,过程等是否与保存在版本表中的数据库版本同步。

How to track those changes? I do not need to track what is changed but only need to check if database tables, views, procedures, etc. are in sync with database version that is saved in Version table.

为什么我需要这个?当进行部署时,我需要检查数据库是否正确。此外,并不是所有的表或其他数据库对象都应该被跟踪。是否可以在不使用触发器的情况下进行检查?是否可以在没有第三方工具的情况下完成?数据库是否有校验和?

Why I need this? When doing deployment I need to check that database is "correct". Also, not all tables or other database objects should be tracked. Is it possible to check without using triggers? Is it possible to be done without 3rd party tools? Do databases have checksums?

假设我们使用SQL Server 2005.

Lets say that we use SQL Server 2005.

编辑:

我想我应该提供更多有关我们当前环境的信息 - 我们有一个基线与所有脚本创建基本版本(包括数据对象和元数据为我们的应用程序)。但是,这种基本版本的许多安装具有一些附加的数据库对象(附加的表,视图,过程等)。当我们在base版本中做一些更改时,我们还必须更新一些安装(不是全部) - 那时我们要检查base是否处于正确的状态。

I think I should provide a bit more information about our current environment - we have a "baseline" with all scripts needed to create base version (includes data objects and "metadata" for our app). However, there are many installations of this "base" version with some additional database objects (additional tables, views, procedures, etc.). When we make some change in "base" version we also have to update some installations (not all) - at that time we have to check that "base" is in correct state.

感谢

推荐答案

您似乎违反了数据库工作的三条规则。对于每个开发人员使用一个数据库以及为您的模式使用一个权威来源已经有很多帮助。然后,我不确定您是否有基准,更重要的是,您正在使用更改脚本。最后,您可以在视图,存储过程和喜欢分支和合并

You seem to be breaking the first and second rule of "Three rules for database work". Using one database per developer and a single authoritative source for your schema would already help a lot. Then, I'm not sure that you have a Baseline for your database and, even more important, that you are using change scripts. Finally, you might find some other answers in Views, Stored Procedures and the Like and in Branching and Merging.

实际上,所有这些链接都在Jeff Atwood的这篇精彩文章中提及:在版本控制下获取数据库。 A必须读取IMHO。

Actually, all these links are mentioned in this great article from Jeff Atwood: Get Your Database Under Version Control. A must read IMHO.

这篇关于验证数据库更改(版本控制)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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