I have created an SSDT project from an existing database. It included existing trigger inside the tablename.sql file.
CREATE TABLE [dbo].[TableName] (
[ID] INT NULL
)
GO
CREATE TRIGGER trgTableName ON dbo.TableName
FOR INSERT
AS
BEGIN
....
END
GO
DISABLE TRIGGER [dbo].[trgTableName] ON [dbo].[TableName]; /* My trigger is currently disabled */
GO
However, whenever I modify my trigger, SSDT enables it again. It does not consider Trigger disable property while deployment.
Is there anyway I can get SSDT to disable the trigger (if it is disabled already on the database)?
One of the ways I am thinking is to add as a post deployment script. However, it would be good to use existing SSDT feature for this instead of manually adding a post deployment script.
EDIT: It looks like SQL server automatically enables a trigger if we update them. In my case, there is an update to the trigger so it enables the trigger. However, SSDT does not disable it after the update.