<?xml version="1.0" encoding="iso-8859-1" ?>

<table>
  <base>CRM/Core</base>
  <class>Discount</class>
  <name>civicrm_discount</name>
  <comment>Stores discounts for events on the basis of date</comment>
  <add>2.1</add>
  <log>true</log>
  <field>
    <name>id</name>
    <title>Discount ID</title>
    <type>int unsigned</type>
    <required>true</required>
    <comment>primary key</comment>
    <html>
      <type>Number</type>
    </html>
    <add>2.1</add>
  </field>
  <primaryKey>
    <name>id</name>
    <autoincrement>true</autoincrement>
  </primaryKey>
  <field>
    <name>entity_table</name>
    <title>Entity Table</title>
    <type>varchar</type>
    <length>64</length>
    <pseudoconstant>
      <callback>CRM_Core_BAO_Discount::entityTables</callback>
    </pseudoconstant>
    <required>true</required>
    <comment>physical tablename for entity being joined to discount, e.g. civicrm_event</comment>
    <add>2.1</add>
  </field>
  <field>
    <name>entity_id</name>
    <title>Entity ID</title>
    <type>int unsigned</type>
    <required>true</required>
    <comment>FK to entity table specified in entity_table column.</comment>
    <add>2.1</add>
  </field>
  <dynamicForeignKey>
    <idColumn>entity_id</idColumn>
    <typeColumn>entity_table</typeColumn>
    <add>2.1</add>
  </dynamicForeignKey>
  <index>
    <name>index_entity</name>
    <fieldName>entity_table</fieldName>
    <fieldName>entity_id</fieldName>
    <add>2.1</add>
  </index>
  <field>
    <name>price_set_id</name>
    <uniqueName>participant_discount_name</uniqueName>
    <title>Price Set ID</title>
    <type>int unsigned</type>
    <required>true</required>
    <pseudoconstant>
      <table>civicrm_price_set</table>
      <keyColumn>id</keyColumn>
      <labelColumn>title</labelColumn>
    </pseudoconstant>
    <export>true</export>
    <comment>FK to civicrm_price_set</comment>
    <html>
      <label>Price Set</label>
      <type>Select</type>
      <controlField>entity_id</controlField>
    </html>
    <add>4.3</add>
  </field>
  <foreignKey>
    <name>price_set_id</name>
    <table>civicrm_price_set</table>
    <key>id</key>
    <add>4.3</add>
    <onDelete>CASCADE</onDelete>
  </foreignKey>
  <index>
    <name>index_entity_option_id</name>
    <fieldName>entity_table</fieldName>
    <fieldName>entity_id</fieldName>
    <fieldName>price_set_id</fieldName>
    <add>2.1</add>
  </index>
  <field>
    <name>start_date</name>
    <title>Discount Start Date</title>
    <type>date</type>
    <comment>Date when discount starts.</comment>
    <add>2.1</add>
  </field>
  <field>
    <name>end_date</name>
    <title>Discount End Date</title>
    <type>date</type>
    <comment>Date when discount ends.</comment>
    <add>2.1</add>
  </field>
</table>
