CREATE TABLE [dbo].[AdminHistory]
(
[AdminHistoryId] [bigint] NOT NULL IDENTITY(1, 1),
[ChangedBy] [int] NOT NULL,
[ChangedOn] [datetime] NOT NULL,
[AdminHistoryFieldFid] [int] NULL,
[AdminHistoryRecordFid] [bigint] NULL,
[ChangedFrom] [nvarchar] (4000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ChangedTo] [nvarchar] (4000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AdminHistory] ADD CONSTRAINT [PK_AdminHistory] PRIMARY KEY CLUSTERED ([AdminHistoryId]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_AdminHistory_ChangedOn] ON [dbo].[AdminHistory] ([ChangedOn] DESC) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AdminHistory] ADD CONSTRAINT [FK_AdminHistory_AdminHistoryField] FOREIGN KEY ([AdminHistoryFieldFid]) REFERENCES [dbo].[AdminHistoryField] ([AdminHistoryFieldId])
GO
ALTER TABLE [dbo].[AdminHistory] ADD CONSTRAINT [FK_AdminHistory_AdminHistoryRecord] FOREIGN KEY ([AdminHistoryRecordFid]) REFERENCES [dbo].[AdminHistoryRecord] ([AdminHistoryRecordId])
GO
ALTER TABLE [dbo].[AdminHistory] ADD CONSTRAINT [FK_AdminHistory_SysUser] FOREIGN KEY ([ChangedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON [dbo].[AdminHistory] TO [MssExec]
GRANT INSERT ON [dbo].[AdminHistory] TO [MssExec]
GRANT DELETE ON [dbo].[AdminHistory] TO [MssExec]
GRANT UPDATE ON [dbo].[AdminHistory] TO [MssExec]
GO