Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSDT Composite Database Reference with PostDeploy

I have two SSDT projects. Database1 references Database2.

Database projects

When deploying Database1, Table2 (from Database2) is deployed as expected. That is because when I am deploying, the check box "Include composite objects" is checked.

The problem is that only the schema/objects from Database2 are deployed with Database1. The "Script.PostDeployment.sql" file is not generated in the script as a part of the Database1 deployment. It is, however, included in the script when I deploy Database2 directly to the target database.

How do I include the pre/post deploy scripts from referenced dacpac files or SSDT projects?

like image 257
Paul Knopf Avatar asked Aug 21 '12 07:08

Paul Knopf


1 Answers

I believe you are going to have to have the post deployment script of database 1 call the post deployment script of database 2. Like

 Use SQLCMD syntax to include a file in the post-deployment script.         
 Example:      :r .\myfile.sql  

I can't see any other way as in most cases the post deployment script of another DB should probably not be ran when deploying. You may also want to consider refactoring the part of the script that needs to be ran on the deployment of both databases into its own file, and referencing it in both post deployments scripts.

like image 157
Andrew Clear Avatar answered Sep 27 '22 23:09

Andrew Clear