Can I automatically generate a change script using a .scmp file?

本秂侑毒 提交于 2019-12-25 03:34:08

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/29109794/can-i-automatically-generate-a-change-script-using-a-scmp-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!