IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[CustomerWareDiscountXtab]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[CustomerWareDiscountXtab]
  (
    [FK_CustomerNumber] [int] NOT NULL,
    [FK_WareNumber] [int] NOT NULL,
    [FK_HotelCustomerNumber] [int] NOT NULL,
    [DiscountValue] [float] NOT NULL,
    [IsFixedAmount] [bit] NOT NULL,
    CONSTRAINT [PK_CustomerWareDiscountXtab_1] PRIMARY KEY CLUSTERED 
    (
      [FK_CustomerNumber] ASC,
      [FK_WareNumber] ASC,
      [FK_HotelCustomerNumber] ASC
    )
  ) ON [PRIMARY]

  ALTER TABLE [dbo].[CustomerWareDiscountXtab]  WITH CHECK ADD  CONSTRAINT [FK_CustomerWareDiscountXtab_Customer] FOREIGN KEY([FK_CustomerNumber])
  REFERENCES [dbo].[Customer] ([CustomerNumber])

  ALTER TABLE [dbo].[CustomerWareDiscountXtab] CHECK CONSTRAINT [FK_CustomerWareDiscountXtab_Customer]

  ALTER TABLE [dbo].[CustomerWareDiscountXtab]  WITH CHECK ADD  CONSTRAINT [FK_CustomerWareDiscountXtab_Ware] FOREIGN KEY([FK_WareNumber])
  REFERENCES [dbo].[Ware] ([WareNumber])

  ALTER TABLE [dbo].[CustomerWareDiscountXtab] CHECK CONSTRAINT [FK_CustomerWareDiscountXtab_Ware]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[ReservationAddressWareDiscountXTab]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[ReservationAddressWareDiscountXTab]
  (
    [FK_ReservationAddressNumber] [int] NOT NULL,
    [FK_WareNumber] [int] NOT NULL,
    [DiscountValue] [float] NOT NULL,
    [IsFixedAmount] [bit] NOT NULL,
    CONSTRAINT [PK_ReservationAddressWareDiscountXTab] PRIMARY KEY CLUSTERED 
    (
      [FK_ReservationAddressNumber] ASC,
      [FK_WareNumber] ASC
    )
  ) ON [PRIMARY]

  ALTER TABLE [dbo].[ReservationAddressWareDiscountXTab]  WITH CHECK ADD  CONSTRAINT [FK_ReservationAddressWareDiscountXTab_ReservationAddress] FOREIGN KEY([FK_ReservationAddressNumber])
  REFERENCES [dbo].[ReservationAddress] ([AddressNumber])

  ALTER TABLE [dbo].[ReservationAddressWareDiscountXTab] CHECK CONSTRAINT [FK_ReservationAddressWareDiscountXTab_ReservationAddress]

  ALTER TABLE [dbo].[ReservationAddressWareDiscountXTab]  WITH CHECK ADD  CONSTRAINT [FK_ReservationAddressWareDiscountXTab_Ware] FOREIGN KEY([FK_WareNumber])
  REFERENCES [dbo].[Ware] ([WareNumber])

  ALTER TABLE [dbo].[ReservationAddressWareDiscountXTab] CHECK CONSTRAINT [FK_ReservationAddressWareDiscountXTab_Ware]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[CampaignCodesWareDiscountXTab]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[CampaignCodesWareDiscountXTab](
    [FK_CampaignCode] [smallint] NOT NULL,
    [FK_HotelCustomerNumber] [int] NOT NULL,
    [FK_WareNumber] [int] NOT NULL,
    [DiscountValue] [float] NOT NULL,
    [IsFixedAmount] [bit] NOT NULL,
    CONSTRAINT [PK_CampaignCodesWareDiscountXTab] PRIMARY KEY CLUSTERED 
    (
      [FK_CampaignCode] ASC,
      [FK_HotelCustomerNumber] ASC,
      [FK_WareNumber] ASC
    )
  ) ON [PRIMARY]

  ALTER TABLE [dbo].[CampaignCodesWareDiscountXTab]  WITH CHECK ADD  CONSTRAINT [FK_CampaignCodesWareDiscountXTab_CampaignCode] FOREIGN KEY([FK_CampaignCode])
  REFERENCES [dbo].[CampaignCodes] ([PK_CampaignCode])

  ALTER TABLE [dbo].[CampaignCodesWareDiscountXTab] CHECK CONSTRAINT [FK_CampaignCodesWareDiscountXTab_CampaignCode]

  ALTER TABLE [dbo].[CampaignCodesWareDiscountXTab]  WITH CHECK ADD  CONSTRAINT [FK_CampaignCodesWareDiscountXTab_HotelCustomer] FOREIGN KEY([FK_HotelCustomerNumber])
  REFERENCES [dbo].[Customer] ([CustomerNumber])

  ALTER TABLE [dbo].[CampaignCodesWareDiscountXTab] CHECK CONSTRAINT [FK_CampaignCodesWareDiscountXTab_HotelCustomer]

  ALTER TABLE [dbo].[CampaignCodesWareDiscountXTab]  WITH CHECK ADD  CONSTRAINT [FK_CampaignCodesWareDiscountXTab_Ware] FOREIGN KEY([FK_WareNumber])
  REFERENCES [dbo].[Ware] ([WareNumber])

  ALTER TABLE [dbo].[CampaignCodesWareDiscountXTab] CHECK CONSTRAINT [FK_CampaignCodesWareDiscountXTab_Ware]
END

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'IsFixedAmount'
    WHERE SysObjects.Name = 'CampaignCodesDiscount'
)
BEGIN
  ALTER TABLE CampaignCodesDiscount ADD IsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'ExtrasDiscountRate'
    WHERE SysObjects.Name = 'CustomerFieldsPerHotel'
)
BEGIN
  ALTER TABLE CustomerFieldsPerHotel ADD ExtrasDiscountRate MONEY NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'AllDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'CustomerFieldsPerHotel'
)
BEGIN
  ALTER TABLE CustomerFieldsPerHotel ADD AllDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'RoomDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'CustomerFieldsPerHotel'
)
BEGIN
  ALTER TABLE CustomerFieldsPerHotel ADD RoomDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'MeetingDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'CustomerFieldsPerHotel'
)
BEGIN
  ALTER TABLE CustomerFieldsPerHotel ADD MeetingDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'HallDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'CustomerFieldsPerHotel'
)
BEGIN
  ALTER TABLE CustomerFieldsPerHotel ADD HallDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'PhoneDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'CustomerFieldsPerHotel'
)
BEGIN
  ALTER TABLE CustomerFieldsPerHotel ADD PhoneDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'PayTVDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'CustomerFieldsPerHotel'
)
BEGIN
  ALTER TABLE CustomerFieldsPerHotel ADD PayTVDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'ExtraDicountIsFixedAmount'
    WHERE SysObjects.Name = 'CustomerFieldsPerHotel'
)
BEGIN
  ALTER TABLE CustomerFieldsPerHotel ADD ExtraDicountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'ExtrasDiscountRate'
    WHERE SysObjects.Name = 'ReservationAddress'
)
BEGIN
  ALTER TABLE ReservationAddress ADD ExtrasDiscountRate MONEY NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'AllDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'ReservationAddress'
)
BEGIN
  ALTER TABLE ReservationAddress ADD AllDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'RoomDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'ReservationAddress'
)
BEGIN
  ALTER TABLE ReservationAddress ADD RoomDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'MeetingDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'ReservationAddress'
)
BEGIN
  ALTER TABLE ReservationAddress ADD MeetingDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'HallDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'ReservationAddress'
)
BEGIN
  ALTER TABLE ReservationAddress ADD HallDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'PhoneDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'ReservationAddress'
)
BEGIN
  ALTER TABLE ReservationAddress ADD PhoneDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'PayTVDiscountIsFixedAmount'
    WHERE SysObjects.Name = 'ReservationAddress'
)
BEGIN
  ALTER TABLE ReservationAddress ADD PayTVDiscountIsFixedAmount BIT NULL
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'ExtraDicountIsFixedAmount'
    WHERE SysObjects.Name = 'ReservationAddress'
)
BEGIN
  ALTER TABLE ReservationAddress ADD ExtraDicountIsFixedAmount BIT NULL
END
GO