我可以使用.scmp文件自动生成更改脚本吗? [英] Can I automatically generate a change script using a .scmp file?

查看:373
本文介绍了我可以使用.scmp文件自动生成更改脚本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在工作中使用数据库项目,并在部署到生产服务器时使用数据库项目,我们当前的流程是使用保存的.scmp文件手动运行比较,该文件将数据库项目与生产数据库进行比较(使用read-只有登录),然后生成一个我们给IT的SQL脚本支持人生产。我们也做一个构建来生成我们的部署后脚本,我们给我们一个人来运行。



我试图自动化这个过程是可能的(以减少错误的机会并使其更有效率)。我想知道是否有办法使用.scmp文件中的预定义选项自动生成sql更改脚本。



此外,还有一个简单的方法将后续部署脚本的附加自动化到架构更改脚本的末尾,所以他只需要运行一个sql文件?



也许有一个很好的方法来做确定方法

解决方案

确定你应该做的是使用sqlpackage.exe从dacpac创建你的脚本这是通过构建ssdt项目生成的。



创建一个批处理脚本来调用它或使其成为您的配置项过程的一部分。



为了过滤输出,有一些新的选项,例如排除ssdt最新版本(2015年3月)中的某些类型,或使用部署过滤器,如:



http://agilesqlclub.codeplex.com ,如果您需要更多的灵活性。 / p>

使用这种方式可以像比较一样过滤部署,还可以将pre / post部署脚本预先/附加到一起,这样一来就可以杀死两只鸟!
Ed


We're using database projects here at work and for our deployment to the production server, our current process is to manually run a compare using a saved .scmp file that compares the database project to our production database (using a read-only login), then generate a SQL script that we give to our I.T. support guy to run on production. We also do a build to generate our post-deployment script, and we give that one to our guy to run as well.

I'm trying to automate as much of this process as possible (to reduce the chances of mistakes and make it more efficient). I'd like to know if there's a way to automatically generate the sql change script using the predefined options in our .scmp file.

Additionally, is there an easy way to automate the appending of the post-deployment script to the end of the schema change script, so he just has one sql file to run?

Perhaps there's a nice way to do the whole thing with powershell or something.

解决方案

Ok what you should do is use sqlpackage.exe to create your script from the dacpac that is produced by building the ssdt project.

Create a batch script to call it or make it a part of your CI process.

To filter the output there are some new options like exclude certain types in the latest (March 2015) release of ssdt or use a deployment filter like:

http://agilesqlclub.codeplex.com if you need more flexibility.

Using this you can filter the deployment like the compare and also the pre/post deploy scripts are pre/appended so you kill two birds with one stone! Ed

这篇关于我可以使用.scmp文件自动生成更改脚本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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