[dbo].[SakariOutgoingMessage]
CREATE TABLE [dbo].[SakariOutgoingMessage]
(
[SakariOutgoingMessageID] [int] NOT NULL IDENTITY(1, 1),
[SakariConversationFID] [int] NOT NULL,
[SakariContactFID] [int] NOT NULL,
[TextMessage] [nvarchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CreatedAt] [datetimeoffset] NOT NULL,
[UpdatedAt] [datetimeoffset] NOT NULL,
[UpdatedInMssAt] [datetimeoffset] NOT NULL,
[SentBy] [int] NULL,
[SakariMessageStatusFID] [int] NOT NULL,
[MessageID] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ErrorMessage] [varchar] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ErrorCode] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[SakariScheduledMessageFID] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[SakariOutgoingMessage] ADD CONSTRAINT [PK_SakariOutgoingMessageID] PRIMARY KEY NONCLUSTERED ([SakariOutgoingMessageID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SakariOutgoingMessage] ADD CONSTRAINT [IX_SakariOutgoingMessage_SakariContactFID_MessageID] UNIQUE CLUSTERED ([SakariContactFID], [MessageID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SakariOutgoingMessage] ADD CONSTRAINT [FK_SakariOutgoingMessage_SakariContact] FOREIGN KEY ([SakariContactFID]) REFERENCES [dbo].[SakariContact] ([SakariContactID])
GO
ALTER TABLE [dbo].[SakariOutgoingMessage] ADD CONSTRAINT [FK_SakariOutgoingMessage_SakariConversation] FOREIGN KEY ([SakariConversationFID]) REFERENCES [dbo].[SakariConversation] ([SakariConversationID])
GO
ALTER TABLE [dbo].[SakariOutgoingMessage] ADD CONSTRAINT [FK_SakariOutgoingMessage_SakariMessageStatus] FOREIGN KEY ([SakariMessageStatusFID]) REFERENCES [dbo].[SakariMessageStatus] ([SakariMessageStatusID])
GO
ALTER TABLE [dbo].[SakariOutgoingMessage] ADD CONSTRAINT [FK_SakariOutgoingMessage_SakariScheduledMessage] FOREIGN KEY ([SakariScheduledMessageFID]) REFERENCES [dbo].[SakariScheduledMessage] ([SakariScheduledMessageID])
GO
ALTER TABLE [dbo].[SakariOutgoingMessage] ADD CONSTRAINT [FK_SakariOutgoingMessage_Sysuser] FOREIGN KEY ([SentBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON [dbo].[SakariOutgoingMessage] TO [MssExec]
GRANT INSERT ON [dbo].[SakariOutgoingMessage] TO [MssExec]
GRANT DELETE ON [dbo].[SakariOutgoingMessage] TO [MssExec]
GRANT UPDATE ON [dbo].[SakariOutgoingMessage] TO [MssExec]
GO