问题
We have a solution with three database projects. All three produced dacpacs are deployed sequentially but for some reason, one of these dacpacs does not run the post-deployment script.
We're using sqlpackage to create a diffscript, and the diffscript does correctly include the post-deployment statements.. here's a snippet
IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT>0 BEGIN
PRINT N'The transacted portion of the database update succeeded.'
COMMIT TRANSACTION
END
ELSE PRINT N'The transacted portion of the database update failed.'
GO
DROP TABLE #tmpErrors
GO
/*
Post-Deployment Script Template
--------------------------------------------------------------------------------------
This file contains SQL statements that will be appended to the build script.
Use SQLCMD syntax to include a file in the post-deployment script.
Example: :r .\myfile.sql
Use SQLCMD syntax to reference a variable in the post-deployment script.
--------------------------------------------------------------------------------------
*/
print 'SCRIPT: dbo.MEMTYPES.data.sql'
Where: a) The Comment is in the Header postdeployment.sql script, which calls other scripts using the standard syntax : :r .\dbo.MEMTYPES.data.sql , and b) The line " print 'SCRIPT: dbo.MEMTYPES.data.sql'" is the first line of the first child script defined in the postdeployment script.
However, when run, the log of the deployment ends with the line:
The transacted portion of the database update succeeded.
Which means the dacpac schema changes were applied (and they were) but presumably no attempt was made to continue in the script to run the post deployment tasks.
Any ideas?
回答1:
As it's a couple of months after I posted the question, and http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/ I guess I should state what the outcome was...
I couldn't find rhyme or reason for the issue other than removing the comments resolved the issue. Now that this has in effect been included in our rules to follow, we haven't come across this issue since.
来源:https://stackoverflow.com/questions/16981612/database-project-not-running-post-deployment-scripts