CREATE TABLE [dbo].[OrderHistory]
(
[OrderHistoryID] [bigint] NOT NULL IDENTITY(1, 1),
[OrderFID] [int] NOT NULL,
[ChangedBy] [int] NOT NULL,
[ChangedOn] [datetime] NOT NULL,
[OrderHistoryFieldFID] [int] NOT NULL,
[ChangedTo] [varchar] (256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ChangedIn] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CustomDescription] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderHistory] ADD CONSTRAINT [PK_OrderHistory] PRIMARY KEY CLUSTERED ([OrderFID], [OrderHistoryID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderHistory] ADD CONSTRAINT [FK_OrderHistory_SysUserFID] FOREIGN KEY ([ChangedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[OrderHistory] ADD CONSTRAINT [FK_OrderHistory_Orders] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[OrderHistory] ADD CONSTRAINT [FK_OrderHistory_OrderHistoryField] FOREIGN KEY ([OrderHistoryFieldFID]) REFERENCES [dbo].[OrderHistoryField] ([OrderHistoryFieldID])
GO
GRANT SELECT ON [dbo].[OrderHistory] TO [MssExec]
GRANT INSERT ON [dbo].[OrderHistory] TO [MssExec]
GRANT DELETE ON [dbo].[OrderHistory] TO [MssExec]
GRANT UPDATE ON [dbo].[OrderHistory] TO [MssExec]
GO