Usually throughout development of a project I will deploy frequently, just to make sure I wont have any problems in production.
通常在一个项目的开发过程中,我会频繁地部署,以确保在生产中不会出现任何问题。
Also, throughout development, I find myself changing the database's schema.
而且,在整个开发过程中,我发现自己正在更改数据库的模式。
How can I easily update the database in production?
如何轻松地更新生产中的数据库?
I have been dropping the old database and reattaching the new one. Is there a faster way to update the deployment database?
我一直在删除旧的数据库并重新连接新的数据库。有更快的方法更新部署数据库吗?
Thanks
谢谢
EDIT
What are some free tools for this?
有什么免费的工具吗?
9 个解决方案
#1
12
Maintain a list of all the change scripts that you apply to your dev database and apply them to the Production database when deploying.
维护您在开发数据库中应用的所有更改脚本的列表,并在部署时将它们应用到生产数据库。
Alternatively, use a third party tool that can compare the two schemas and provide a changescript which you can then run.
另一种方法是使用第三方工具,该工具可以比较这两个模式,并提供一个可以运行的changescript。
#2
8
I try to use tools like RedGate SQL Compare which will show you "diffs" between two versions and actually script out the components that are different. You can also make it a habit to script all of your database revisions so that you have an audit trail of changes you've made and can apply them in a programmatic way when you are ready to deploy.
我尝试使用RedGate SQL Compare之类的工具,它将向您展示两个版本之间的差异,并实际编写出不同的组件。您还可以养成编写所有数据库修订脚本的习惯,以便对所做的更改进行审计跟踪,并在准备部署时以编程方式应用它们。
#3
2
Your best bet is to implement your changes as a set of diff scripts. So rather than dropping a table and recreating it, you script is as ALTER TABLE.
最好的办法是将更改实现为一组diff脚本。因此,您的脚本不是删除一个表并重新创建它,而是作为一个可修改的表。
There are also tools out there that help you do this. If you keep a copy of the original and the new database, you can run a tool against the two which will generate SQL that will take you from one version to another.
还有一些工具可以帮助你做到这一点。如果您保留了原始数据库和新数据库的副本,您可以针对这两个数据库运行一个工具,该工具将生成SQL,使您能够从一个版本转换到另一个版本。
#4
1
I personally like to keep full creation scripts updated, as well as maintaining an upgrade script, whenever I change the schema for a particular release. I have used Red Gate SQL Compare, and it is a very good tool, but prefer to keep the scripts maintained.
我个人喜欢保持完整的创建脚本的更新,以及维护一个升级脚本,每当我更改特定版本的模式时。我使用过Red Gate SQL Compare,它是一个非常好的工具,但是我更喜欢保持脚本的维护。
#5
1
Always write a script to make your schema changes. Place the script in a promotion folder so that when you promote your changes, the scripts are executed to change each environment.
总是编写一个脚本来更改您的模式。将脚本放置在升级文件夹中,以便当您升级更改时,执行脚本以更改每个环境。
#6
0
The Generate Scripts wizard did exactly what I needed.
生成脚本向导完成了我所需要的工作。
#7
0
Migrator Dot Net is an awesome tool for versioning your database. It's hard to go back to manually keeping track of scripts and doing database comparisons after you've used migrations.
Migrator。Net是一个很棒的数据库版本控制工具。在您使用了迁移之后,很难回到手工跟踪脚本和进行数据库比较。
#8
0
Visual Studio Database Edition is quite good at this. It keeps your entire schema in source scripts under source control along with the rest of your code. It can analyze your schema for dependencies when you make a change. It can run best practices analysis. And it can generate a .dbschema file that can is used by the deployment tool to upgrade your database to the current schema.
Visual Studio数据库版本在这方面做得很好。它将您的整个模式保存在源代码脚本中,并将代码的其余部分置于源代码控制之下。当您进行更改时,它可以分析您的模式是否具有依赖性。它可以运行最佳实践分析。它还可以生成.dbschema文件,部署工具可以使用该文件将数据库升级到当前模式。
You can actually automate this with continuos integration and build drops straight to test environment, staging environment and even production environment. What that means is that when you check in into the test branch, the build machine will build product, run the build validation tests and deploy it on your development server. When you reverse integrate from test branch to main branch, the build machine builds the product, runs the BVTs and deploys is on your staging test/acceptance server. And when you integrate into the release branch the build machine will build, test and finally deploy on production. Now is true, not many orgs are ready to go that far and let the continuos build process deploy automatically on the live production servers and I reckon it is kinda radical thinking. But I say you should trust more your automated BVTs and automated processes than any manual test and deployment.
实际上,您可以使用continuos集成实现自动化,并直接构建drop到测试环境、阶段环境甚至生产环境。这意味着,当您检入测试分支时,构建机器将构建产品,运行构建验证测试并将其部署到您的开发服务器上。当您从测试分支反向集成到主分支时,构建机器将构建产品,运行BVTs,并在登台测试/接受服务器上部署。当您集成到发布分支时,构建机器将构建、测试并最终部署到产品上。现在是真的,没有多少组织准备好这么做,让continuos构建过程自动部署到实时生产服务器上,我认为这是一种激进的想法。但是我认为您应该更信任您的自动化BVTs和自动化流程,而不是任何手工测试和部署。
#9
0
Try DBSourceTools.
http://dbsourcetools.codeplex.com
Its open source, and will script an entire database
- tables, views, procs and data to disk, and then allow you to re-create that database through a deployment target.
It's specifically designed to help developers get their databases under source code control.
DBSourceTools试试。http://dbsourcetools.codeplex.com作为它的开源站点,它将为整个数据库编写脚本——表、视图、进程和数据到磁盘,然后允许您通过部署目标重新创建这个数据库。它是专门设计来帮助开发人员将他们的数据库置于源代码控制之下。
#1
12
Maintain a list of all the change scripts that you apply to your dev database and apply them to the Production database when deploying.
维护您在开发数据库中应用的所有更改脚本的列表,并在部署时将它们应用到生产数据库。
Alternatively, use a third party tool that can compare the two schemas and provide a changescript which you can then run.
另一种方法是使用第三方工具,该工具可以比较这两个模式,并提供一个可以运行的changescript。
#2
8
I try to use tools like RedGate SQL Compare which will show you "diffs" between two versions and actually script out the components that are different. You can also make it a habit to script all of your database revisions so that you have an audit trail of changes you've made and can apply them in a programmatic way when you are ready to deploy.
我尝试使用RedGate SQL Compare之类的工具,它将向您展示两个版本之间的差异,并实际编写出不同的组件。您还可以养成编写所有数据库修订脚本的习惯,以便对所做的更改进行审计跟踪,并在准备部署时以编程方式应用它们。
#3
2
Your best bet is to implement your changes as a set of diff scripts. So rather than dropping a table and recreating it, you script is as ALTER TABLE.
最好的办法是将更改实现为一组diff脚本。因此,您的脚本不是删除一个表并重新创建它,而是作为一个可修改的表。
There are also tools out there that help you do this. If you keep a copy of the original and the new database, you can run a tool against the two which will generate SQL that will take you from one version to another.
还有一些工具可以帮助你做到这一点。如果您保留了原始数据库和新数据库的副本,您可以针对这两个数据库运行一个工具,该工具将生成SQL,使您能够从一个版本转换到另一个版本。
#4
1
I personally like to keep full creation scripts updated, as well as maintaining an upgrade script, whenever I change the schema for a particular release. I have used Red Gate SQL Compare, and it is a very good tool, but prefer to keep the scripts maintained.
我个人喜欢保持完整的创建脚本的更新,以及维护一个升级脚本,每当我更改特定版本的模式时。我使用过Red Gate SQL Compare,它是一个非常好的工具,但是我更喜欢保持脚本的维护。
#5
1
Always write a script to make your schema changes. Place the script in a promotion folder so that when you promote your changes, the scripts are executed to change each environment.
总是编写一个脚本来更改您的模式。将脚本放置在升级文件夹中,以便当您升级更改时,执行脚本以更改每个环境。
#6
0
The Generate Scripts wizard did exactly what I needed.
生成脚本向导完成了我所需要的工作。
#7
0
Migrator Dot Net is an awesome tool for versioning your database. It's hard to go back to manually keeping track of scripts and doing database comparisons after you've used migrations.
Migrator。Net是一个很棒的数据库版本控制工具。在您使用了迁移之后,很难回到手工跟踪脚本和进行数据库比较。
#8
0
Visual Studio Database Edition is quite good at this. It keeps your entire schema in source scripts under source control along with the rest of your code. It can analyze your schema for dependencies when you make a change. It can run best practices analysis. And it can generate a .dbschema file that can is used by the deployment tool to upgrade your database to the current schema.
Visual Studio数据库版本在这方面做得很好。它将您的整个模式保存在源代码脚本中,并将代码的其余部分置于源代码控制之下。当您进行更改时,它可以分析您的模式是否具有依赖性。它可以运行最佳实践分析。它还可以生成.dbschema文件,部署工具可以使用该文件将数据库升级到当前模式。
You can actually automate this with continuos integration and build drops straight to test environment, staging environment and even production environment. What that means is that when you check in into the test branch, the build machine will build product, run the build validation tests and deploy it on your development server. When you reverse integrate from test branch to main branch, the build machine builds the product, runs the BVTs and deploys is on your staging test/acceptance server. And when you integrate into the release branch the build machine will build, test and finally deploy on production. Now is true, not many orgs are ready to go that far and let the continuos build process deploy automatically on the live production servers and I reckon it is kinda radical thinking. But I say you should trust more your automated BVTs and automated processes than any manual test and deployment.
实际上,您可以使用continuos集成实现自动化,并直接构建drop到测试环境、阶段环境甚至生产环境。这意味着,当您检入测试分支时,构建机器将构建产品,运行构建验证测试并将其部署到您的开发服务器上。当您从测试分支反向集成到主分支时,构建机器将构建产品,运行BVTs,并在登台测试/接受服务器上部署。当您集成到发布分支时,构建机器将构建、测试并最终部署到产品上。现在是真的,没有多少组织准备好这么做,让continuos构建过程自动部署到实时生产服务器上,我认为这是一种激进的想法。但是我认为您应该更信任您的自动化BVTs和自动化流程,而不是任何手工测试和部署。
#9
0
Try DBSourceTools.
http://dbsourcetools.codeplex.com
Its open source, and will script an entire database
- tables, views, procs and data to disk, and then allow you to re-create that database through a deployment target.
It's specifically designed to help developers get their databases under source code control.
DBSourceTools试试。http://dbsourcetools.codeplex.com作为它的开源站点,它将为整个数据库编写脚本——表、视图、进程和数据到磁盘,然后允许您通过部署目标重新创建这个数据库。它是专门设计来帮助开发人员将他们的数据库置于源代码控制之下。