Visual Studio 数据库项目回滚脚本
我正在使用 Visual Studio 2010 中的数据库项目生成一个脚本来部署我的数据库(及其更改)。这很好用。
有没有办法让 Visual Studio 数据库项目生成回滚脚本以及部署脚本。
我不想在部署时回滚事务;但是假设我部署了它,并且我的存储过程有一个被忽视的性能问题,一周后出现该问题,需要回滚到数据库的先前版本。
有没有一种方法可以在构建/部署时生成回滚脚本,该脚本将撤消部署脚本所做的任何更改。
编辑:如果我们忽略我正在使用数据库项目:生成数据库的升级和降级路径的好方法是什么?
这一代需要成为自动化构建过程的一部分。
I'm using the Database project in visual studio 2010 to generate a script to deploy my database (and it's changes). This works great.
Is there a way to have Visual Studio database project generate a rollback script as well as the deployment script.
I'm not looking for rolling back the transaction while deploying; but say I deploy it and my stored procedure has an overlooked performance issue that comes up a week later that requires a rollback to the previous version of the database.
Is there a way to generate the rollback script at build/deploy time that will undo whatever changes the deployment script made.
EDIT: If we ignore that I'm using a database project: What is a good way to have an upgrade and downgrade path for a database generated?
This generation needs to be part of an automated build process.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建回滚脚本 使用 VS2010 进行架构比较时,就像交换源和目标中指定的数据库名称一样简单。
这样,VS2010 将创建一个回滚脚本,其中包含针对存储过程的 drop 语句。
To create a rollback script While doing a schema compare using VS2010, It is as simple as swapping the db names specified in the source and target.
This way VS2010 would create a rollback script which would have drop statements against your stored proc.
我还没有见过这样的事情。
我认为您需要重新考虑这种方法,因为您仍然需要修复数据库项目中的存储过程,否则您将在下次部署时重新部署“坏”版本。 (我确信您已经意识到这一点,但有时指出明显的情况并没有帮助!)
如果您需要同时将存储过程的旧版本恢复到服务器,我会想最简单的方法是从源代码管理中获取以前的版本并手动部署它。
I've not seen anything like that.
I think you need to reconsider this approach, as you'd still need to fix the stored proc in your database project, otherwise you'd just be re-deploying the "bad" version the next time you deploy. (I'm sure you're already aware of that, but it doesn't help to point out the obvious sometimes!)
If you need to restore an old version of the sproc to the server in the mean time, I would have thought that the easiest thing to do would be to get the previous version from source control and manually deploy that.
您可以在发布之前创建数据库的备份,然后在出现问题时从备份中恢复。显然,自备份以来,您还会丢失任何数据更改(无论是作为发布的一部分还是随后进行的)。
我的另一个想法是在发布之前创建一个快照。创建快照的操作非常轻量。我不确定您是否希望将快照保留一周,但如果发布出错,那么我认为从快照恢复比从完整备份恢复更快。我很想听听人们对这个想法的任何评论。
You could create a backup of the database before the release and then just restore from the backup if things go wrong. Obviously you'd also loose any data changes (either made as part of the release or subsequently) since the backup was taken.
Another idea I had was to create a snapshot before the release. The operation to create a snapshot is very light weight. I'm not sure you'd want to keep the snapshot for a week, but if the release went wrong then I think it would be quicker to restore from a snapshot than from a full backup. I would be interested to hear any comments people have on this idea.