I have two SSDT projects. Database1 references Database2.
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With