[dbo].[OutgoingEmailFailure]
CREATE TABLE [dbo].[OutgoingEmailFailure]
(
[OutgoingEmailFailureID] [int] NOT NULL IDENTITY(1, 1),
[OutgoingEmailFID] [int] NOT NULL,
[OutgoingEmailBatchFailureFID] [int] NOT NULL,
[EnqueuedAt] [datetimeoffset] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OutgoingEmailFailure] ADD CONSTRAINT [PK_OutgoingEmailFailure] PRIMARY KEY CLUSTERED ([OutgoingEmailFailureID]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_OutgoingEmailFailure_OutgoingEmailFID_OutgoingEmailBatchFailureFID] ON [dbo].[OutgoingEmailFailure] ([OutgoingEmailFID], [OutgoingEmailBatchFailureFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OutgoingEmailFailure] ADD CONSTRAINT [FK_OutgoingEmailFailure_OutgoingEmailBatchFailure] FOREIGN KEY ([OutgoingEmailBatchFailureFID]) REFERENCES [dbo].[OutgoingEmailBatchFailure] ([OutgoingEmailBatchFailureId])
GO
ALTER TABLE [dbo].[OutgoingEmailFailure] ADD CONSTRAINT [FK_OutgoingEmailFailure_OutgoingEmail] FOREIGN KEY ([OutgoingEmailFID]) REFERENCES [dbo].[OutgoingEmail] ([OutgoingEmailID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[OutgoingEmailFailure] TO [MssExec]
GRANT INSERT ON [dbo].[OutgoingEmailFailure] TO [MssExec]
GRANT DELETE ON [dbo].[OutgoingEmailFailure] TO [MssExec]
GRANT UPDATE ON [dbo].[OutgoingEmailFailure] TO [MssExec]
GO