CREATE TABLE [dbo].[ATEventTriggerDefinition] (
    [Id]     INT                   NOT NULL IDENTITY(1,1),
    [ProcessId]     INT            NOT NULL,
    [TemplateId]    INT            NOT NULL,
    [TriggerName]   NVARCHAR (255) NOT NULL,
    [HookId]        INT            NOT NULL,
    [ActionId]      INT            NOT NULL,
    [Description]   NVARCHAR (255) NULL,
    [TriggerAction] NVARCHAR(MAX)  NOT NULL,
    CONSTRAINT [PK_ATEventTriggerDefinition] PRIMARY KEY NONCLUSTERED ([Id] ASC),
    CONSTRAINT [ATEventTrigger_ProcessDefinition] FOREIGN KEY ([ProcessId]) REFERENCES [dbo].[ATProcessDefinition] ([ProcessID]),
    CONSTRAINT [ATEventTrigger_Template] FOREIGN KEY ([TemplateId]) REFERENCES [dbo].[ATTemplates] ([Id]),
    CONSTRAINT [ATEventTrigger_Hook] FOREIGN KEY ([HookId]) REFERENCES [dbo].[ATTriggerHook] ([Id]),
    CONSTRAINT [ATEventTrigger_Action] FOREIGN KEY ([ActionId]) REFERENCES [dbo].[ATTriggerAction] ([Id])
);