Question

There are several types of scripts in database project: PreDeployment, PostDeployment, Build and NotInBuild.
Whereas the first two can exist only in a single copy, build scripts can be in abundance.

I cannot find the information when and in what order buid scripts are executed.
Does it imply that build scripts mustn't depend on the order of execution or I miss something?

No correct solution

OTHER TIPS

You can have one script marked as "PreDeployment" and one script marked as "PostDeployment". Those scripts will use SQLCMD syntax to include other scripts (build type "none") as part of that process.

The pre-deploy script will be compiled to include all scripts included in the order you specify. The Post-deploy script will be compiled in the same manner.

To include a file in the pre or post deploy script, you use a syntax like:

:r .\IncludeThisScript.sql

When you publish, the Pre-deploy script will run first, then the DB changes will be made, then the post-deploy script will run. It's also worth noting that the DB Change script is generated with no knowledge of what the pre/post deploy scripts will do or have done. If you create a table in the pre-deploy script and also try to create it in the project, the project will likely fail because the table already exists.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top