CREATE TABLE [dbo].[XLedgerAccount]
(
[XLedgerAccountId] [int] NOT NULL IDENTITY(1, 1),
[ExternalDbId] [bigint] NOT NULL,
[CreatedOn] [datetimeoffset] NOT NULL,
[LastImportedOn] [datetimeoffset] NOT NULL,
[AccountingAccountFid] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XLedgerAccount] ADD CONSTRAINT [PK_XLedgerAccount] PRIMARY KEY NONCLUSTERED ([XLedgerAccountId]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XLedgerAccount] ADD CONSTRAINT [IX_XLedgerAccount_AccountingAccountFid] UNIQUE NONCLUSTERED ([AccountingAccountFid]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XLedgerAccount] ADD CONSTRAINT [IX_XLedgerAccount_ExternalDbId] UNIQUE CLUSTERED ([XLedgerAccountId]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XLedgerAccount] ADD CONSTRAINT [FK_XLedgerAccount_AccountingAccount] FOREIGN KEY ([AccountingAccountFid]) REFERENCES [dbo].[AccountingAccount] ([AccountingAccountId])
GO
GRANT SELECT ON [dbo].[XLedgerAccount] TO [MssExec]
GRANT INSERT ON [dbo].[XLedgerAccount] TO [MssExec]
GRANT DELETE ON [dbo].[XLedgerAccount] TO [MssExec]
GRANT UPDATE ON [dbo].[XLedgerAccount] TO [MssExec]
GO