CREATE TABLE [dbo].[ARCustomerMessages]
(
[MessageID] [int] NOT NULL IDENTITY(1, 1),
[CustomerID] [int] NOT NULL,
[MessageTypeID] [int] NOT NULL,
[Subject] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Message] [varchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Recurring] [bit] NOT NULL CONSTRAINT [DF_ARCustomerMessages_Recurring] DEFAULT ((0)),
[ExpDate] [datetime] NULL,
[CreatorID] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[UpdatorID] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CreateDate] [datetime] NOT NULL CONSTRAINT [DF_ARCustomerMessages_CreateDate] DEFAULT (getdate()),
[LastUpdate] [datetime] NOT NULL CONSTRAINT [DF_ARCustomerMessages_LastUpdate] DEFAULT (getdate()),
[Active] [bit] NOT NULL CONSTRAINT [DF_ARCustomerMessages_Active] DEFAULT ((1))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ARCustomerMessages] ADD CONSTRAINT [PK_ARCustomerMessages] PRIMARY KEY CLUSTERED ([MessageID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ARCustomerMessages] ADD CONSTRAINT [IX_ARCustomerMessages_CustomerID_MessageTypeID] UNIQUE NONCLUSTERED ([CustomerID], [MessageTypeID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ARCustomerMessages] ADD CONSTRAINT [FK_ARCustomerMessages_CustomerID_ARCustomers] FOREIGN KEY ([CustomerID]) REFERENCES [dbo].[ARCustomers] ([CustomerID])
GO