--
-- BA/20110919: 
--
-- FIXES:
-- 
-- 
-- 

IF NOT EXISTS (SELECT 1 FROM sysobjects WHERE name = 'CampaignCodesDiscount')
CREATE TABLE [dbo].[CampaignCodesDiscount](
	[PK_CampaignCode] [smallint] NOT NULL,
	[DiscountType] [int] NOT NULL,
	[Value] [float] NOT NULL,
 CONSTRAINT [PK_CampaignCodesDiscount] PRIMARY KEY CLUSTERED 
(
	[PK_CampaignCode] ASC,
	[DiscountType] ASC
) ON [PRIMARY]
) ON [PRIMARY]

GO

IF NOT EXISTS (SELECT * FROM information_schema.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME = 'FK_CampaignCodesDiscount_CampaignCodes')
ALTER TABLE [dbo].[CampaignCodesDiscount]  WITH CHECK ADD  CONSTRAINT [FK_CampaignCodesDiscount_CampaignCodes] FOREIGN KEY([PK_CampaignCode])
REFERENCES [dbo].[CampaignCodes] ([PK_CampaignCode])
GO
