[dbo].[SakariIncomingMessage]
CREATE TABLE [dbo].[SakariIncomingMessage]
(
[SakariIncomingMessageID] [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,
[ImportedIntoMssAt] [datetimeoffset] NOT NULL,
[MessageID] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[SakariIncomingMessage] ADD CONSTRAINT [PK_SakariIncomingMessageID] PRIMARY KEY NONCLUSTERED ([SakariIncomingMessageID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SakariIncomingMessage] ADD CONSTRAINT [IX_SakariInomingMessage_SakariContactFID_MessageID] UNIQUE CLUSTERED ([SakariContactFID], [MessageID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SakariIncomingMessage] ADD CONSTRAINT [FK_SakariIncomingMessage_SakariContact] FOREIGN KEY ([SakariContactFID]) REFERENCES [dbo].[SakariContact] ([SakariContactID])
GO
ALTER TABLE [dbo].[SakariIncomingMessage] ADD CONSTRAINT [FK_SakariIncomingMessage_SakariConversation] FOREIGN KEY ([SakariConversationFID]) REFERENCES [dbo].[SakariConversation] ([SakariConversationID])
GO
GRANT SELECT ON [dbo].[SakariIncomingMessage] TO [MssExec]
GRANT INSERT ON [dbo].[SakariIncomingMessage] TO [MssExec]
GRANT DELETE ON [dbo].[SakariIncomingMessage] TO [MssExec]
GRANT UPDATE ON [dbo].[SakariIncomingMessage] TO [MssExec]
GO