处理数据库模式中的更改

发布于 2024-09-19 02:31:05 字数 458 浏览 3 评论 0原文

我正处于构建应用程序的初始阶段,该应用程序有望以 1000 的价格出售 - 更有可能是数百,但无论哪种方式都足以引起数据库架构更改的严重头痛。

我相当受限于 windows / .net / sql 服务器环境,因为我们的许多客户将自行托管我在他们的网络服务器中构建的应用程序,并且安装在他们的服务器上的额外位永远不会顺利进行,并且总是有一些投诉/因此而失去业务。所以 sqlalchemy 已经过时了,因为它在 python 中运行。

我想要的是一个可以让我在应用程序版本之间轻松迁移的工具。我发现了 migrator.net 并且以前使用过它,但从未在生产中使用过,因为开发团队似乎每年只对其进行开发,而不是一个活跃的项目。

有哪些替代方法可用?

更新 我忘了提到我希望能够在持续集成环境中使用它,因此虽然 data dude 和 sql Compare 是很好的 GUI 工具,但我确实自动化了。

I am in the fairly initial stages of building an app which will hopefully be sold in the 1000's - more likely it'll be hundreds, but either way more than enough to cause a good sized headache for database schema changes.

I'm rather restricted to a windows / .net / sql server environment as a number of our customers will be self hosting the app I'm building in their web servers and extra bits installed on their servers never goes well and there's always a number of complaints / lost business as a result. So sqlalchemy is out, as it runs in python.

What I'm after is a tool that will allow me to easily migrate between versions of the application. I’ve found migrator.net and I’ve used it before, but never in production as the development team appears to only work on it annually, not exactly an active project.

What alternatives approaches are available?

UPDATE
I forgot to mention that I want to be able to use this in a continuous integration environment, so whilst data dude and sql compare are nice gui tools, I really automation.

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

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

发布评论

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

评论(4

放我走吧 2024-09-26 02:31:05

如果您使用 Visual Studio 2010 Ultimate/Premium Edition 或 Visual Studio Team/Database Edition 2008,您将在 Visual Studio 中找到所需的一切。

您可以比较两个数据库(例如,dev 和 prod)并生成用于修改数据的 SQL 脚本。您可以轻松地从比较中排除某些表或某些列。您还可以检查结果并从脚本的生成中排除一些条目。因此,我们可以轻松灵活地生成可用于部署数据库中的更改的脚本。您可以从结构上分别比较两个数据库的数据架构比较)。只需进入“数据”菜单并选择“架构比较”或“数据比较”。您可以阅读 http://msdn.microsoft.com/en-us/library /dd193250.aspxhttp://msdn.microsoft.com /en-us/library/dd193261.aspx 了解其工作原理。因此,您可以使用 prod 中的数据刷新 dev 中的数据,或者生成将 prod 数据库修改为 dev 数据库的最新版本的脚本。

我开始在 Vinsual Studio Team Edition 2008 中使用此功能,并在 Visual Studio 2010 Ultimate 中继续使用它。这正是我所需要的。在某些情况下,我需要修改一些脚本,但 95% 的工作都是由 Visual Studio 完成的。

如果您无法使用 VS2010 Ultimate 或 Premium,并且没有 VS2008 Team 或 Database Edition,我建议您查看 的一些产品http://www.red-gate.com/ (如 http://www.red-gate.com/products/SQL_Compare/index.htm)具有接近的功能。

If you use Visual Studio 2010 Ultimate/Premium Edition or Visual Studio Team/Database Edition 2008 you will find all you need in the Visual Studio.

You can compare two databases (for example, dev and prod) and generate SQL Script for modifying the data. You can easy exclude some tables or some columns from the comparing. You can also examine the results and exclude some entries from generation of the script. So one can easy and flexible generate scripts which can de used for deployment of the changes in the database. You can separetely compare the data of two databases from the structure (schema comparing). Just go in "Data" menu and choose "Schema Compare" or "Data Compare". You can read http://msdn.microsoft.com/en-us/library/dd193250.aspx and http://msdn.microsoft.com/en-us/library/dd193261.aspx to understand how it works. So you can refresh data in dev with the data from prod or generate scripts which modify prod database to the last version of the dev database.

I started to use this feature with Vinsual Studio Team Edition 2008 and continue to use it Visual Studio 2010 Ultimate. It is exactly what I need. In some cases I need modify a little the scripts, but 95% of the job do Visual Studio.

If you can not VS2010 Ultimate or Premium and no VS2008 Team or Database Editions I would you recommend to look at some products of http://www.red-gate.com/ (like http://www.red-gate.com/products/SQL_Compare/index.htm) with the close features.

你列表最软的妹 2024-09-26 02:31:05

Red_Gate 的 SQl Compare 非常适合保持两个数据库同步。

但是,我认为关键是将源代码管理中的更改保留在特定版本下。像对待属于某个版本的任何其他代码一样对待您的 sql 代码。切勿允许您的开发人员使用 GUI 进行更改,所有更改都应编写脚本并作为版本的一部分放入源代码管理中。一旦你这样做了,如果有人使用版本1并且你想将他们升级到版本2.3,那么你只需要按顺序运行每个版本的脚本,你就会有一个版本2.3的数据库。

Red_Gate's SQl Compare is good for keeping two databases in synch.

However, I think the ciritical thing is to keep your changes in Source Control under a specific version. Treat your sql code just like any other code that belongs to a version. Never allow your devs to make changes using the GUI, All changes should be scripted and put into source control as part ofthe version. Once you do that if someone is in version 1 and you want to upgrade them to version2.3, then you just need to run the sripts for each version in order and you will have a datbase in version 2.3.

恰似旧人归 2024-09-26 02:31:05

将升级脚本添加到您的应用程序中。如果您没有,请创建一个设置表来存储数据库的当前架构版本。示例:

CREATE TABLE SETTINGS(KEY VARCHAR(255), VALUE VARCHAR(255));
INSERT INTO SETTINGS VALUES('version', '1');

启动应用程序时,查询该表(如果不存在则没有安装以前的版本),并检查版本。我只会维护版本 1 到版本 2 的单独升级脚本;版本 2 至 3; 3至4等等。我不会直接维护版本 1 到 3 左右的升级脚本,通常不需要。升级脚本通常包含 ALTER TABLE 和 CREATE TABLE 语句,但有时也包含 UPDATE。

Add the upgrade script to your application. If you don't have that anyway, create a settings table where you store the current schema version of the database. Example:

CREATE TABLE SETTINGS(KEY VARCHAR(255), VALUE VARCHAR(255));
INSERT INTO SETTINGS VALUES('version', '1');

When starting the application, query this table (if it doesn't exist then no previous version was installed), and check the version. I would only maintain separate upgrade scripts for version 1 to version 2; version 2 to 3; 3 to 4 and so on. I wouldn't maintain upgrade script for version 1 to 3 or so directly, usually it's not required. The upgrade scripts typically contain ALTER TABLE and CREATE TABLE statements, but sometimes also UPDATE.

输什么也不输骨气 2024-09-26 02:31:05

SQL Compare 的专业版有一个可用于持续集成的命令行。此处记录:http://downloads.red-gate.com/HelpPDF/ContinouslyIntegrationForDatabasesUsingRedGateSQLTools。 理想情况下,

您可以在源代码管理中维护您的架构,以充分利用它,您可以使用 SQL 源代码控制

SQL Compare 可以在两个给定数据库之间迁移,但源代码控制提供了更成熟的开发流程

如果这没有达到您想要的效果,请对此“答案”发表评论。

The pro version of SQL Compare has a command line that can be used for continuous integration. This is documented here: http://downloads.red-gate.com/HelpPDF/ContinuousIntegrationForDatabasesUsingRedGateSQLTools.pdf

Ideally you would maintain your schema in source control to get the most out of this, which you can do using SQL Source Control.

SQL Compare can migrate between two given databases, but source control provides a more mature development process.

If this doesn't achieve what you're looking for, please comment on this 'answer'.

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