-- +--------------------------------------------------------------------+
-- | Copyright CiviCRM LLC. All rights reserved.                        |
-- |                                                                    |
-- | This work is published under the GNU AGPLv3 license with some      |
-- | permitted exceptions and without any warranty. For full license    |
-- | and copyright information, see https://civicrm.org/licensing       |
-- +--------------------------------------------------------------------+
--
-- Generated from schema.tpl
-- DO NOT EDIT.  Generated by CRM_Core_CodeGen
--


-- +--------------------------------------------------------------------+
-- | Copyright CiviCRM LLC. All rights reserved.                        |
-- |                                                                    |
-- | This work is published under the GNU AGPLv3 license with some      |
-- | permitted exceptions and without any warranty. For full license    |
-- | and copyright information, see https://civicrm.org/licensing       |
-- +--------------------------------------------------------------------+
--
-- Generated from drop.tpl
-- DO NOT EDIT.  Generated by CRM_Core_CodeGen
--
-- /*******************************************************
-- *
-- * Clean up the exisiting tables
-- *
-- *******************************************************/



-- /*******************************************************
-- *
-- * Create new tables
-- *
-- *******************************************************/

-- /*******************************************************
-- *
-- * civicrm_price_field_value_discount
-- *
-- * Discount properties for Discountaddlreg extension
-- *
-- *******************************************************/
CREATE TABLE `civicrm_price_field_value_discount` (


     `id` int unsigned NOT NULL AUTO_INCREMENT  COMMENT 'Unique PriceFieldValueDiscount ID',
     `is_active` tinyint NOT NULL  DEFAULT 0 ,
     `price_field_value_id` int unsigned    COMMENT 'FK to Price Field Value',
     `max_discount_each` decimal(18,9) NOT NULL   COMMENT 'Max dollar amount to discount per person',
     `min_person` int unsigned NOT NULL  DEFAULT 1 COMMENT 'First participant for whom the discount should be applied.',
     `max_persons` int unsigned    COMMENT 'Maximum number of additional participants receiving this discount',
     `discount_field_id` int unsigned NOT NULL   COMMENT 'FK to Price Field' 
,
        PRIMARY KEY (`id`)
 
 
,          CONSTRAINT FK_civicrm_price_field_value_discount_price_field_value_id FOREIGN KEY (`price_field_value_id`) REFERENCES `civicrm_price_field_value`(`id`) ON DELETE CASCADE,          CONSTRAINT FK_civicrm_price_field_value_discount_discount_field_id FOREIGN KEY (`discount_field_id`) REFERENCES `civicrm_price_field`(`id`) ON DELETE CASCADE  
)    ;

 