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

<table>
  <base>CRM/Core</base>
  <class>Setting</class>
  <name>civicrm_setting</name>
  <comment>Table to store civicrm settings for civicrm core and components.</comment>
  <add>4.1</add>
  <field>
    <name>id</name>
    <title>Setting ID</title>
    <type>int unsigned</type>
    <required>true</required>
    <html>
      <type>Number</type>
    </html>
    <add>4.1</add>
  </field>
  <primaryKey>
    <name>id</name>
    <autoincrement>true</autoincrement>
  </primaryKey>
  <field>
    <name>group_name</name>
    <title>Setting Group</title>
    <type>varchar</type>
    <length>64</length>
    <required>true</required>
    <comment>group name for setting element, useful in caching setting elements</comment>
    <add>4.1</add>
    <drop>4.7</drop>
  </field>
  <field>
    <name>name</name>
    <title>Setting Name</title>
    <type>varchar</type>
    <length>255</length>
    <comment>Unique name for setting</comment>
    <add>4.1</add>
  </field>
  <index>
    <name>index_group_name</name>
    <fieldName>group_name</fieldName>
    <fieldName>name</fieldName>
    <add>4.1</add>
    <drop>4.7</drop>
  </index>
  <field>
    <name>value</name>
    <type>text</type>
    <comment>data associated with this group / name combo</comment>
    <serialize>PHP</serialize>
    <html>
      <label>Value</label>
    </html>
    <add>4.1</add>
  </field>
  <field>
    <name>domain_id</name>
    <title>Domain ID</title>
    <type>int unsigned</type>
    <default>NULL</default>
    <pseudoconstant>
      <table>civicrm_domain</table>
      <keyColumn>id</keyColumn>
      <labelColumn>name</labelColumn>
    </pseudoconstant>
    <comment>Which Domain does this setting belong to</comment>
    <html>
      <label>Domain</label>
    </html>
    <add>4.1</add>
  </field>
  <foreignKey>
    <name>domain_id</name>
    <table>civicrm_domain</table>
    <key>id</key>
    <onDelete>CASCADE</onDelete>
    <add>4.1</add>
  </foreignKey>
  <field>
    <name>contact_id</name>
    <title>Contact ID</title>
    <type>int unsigned</type>
    <comment>FK to Contact ID if the setting is localized to a contact</comment>
    <html>
      <label>Contact</label>
    </html>
    <add>4.1</add>
  </field>
  <foreignKey>
    <name>contact_id</name>
    <table>civicrm_contact</table>
    <key>id</key>
    <onDelete>CASCADE</onDelete>
    <add>4.1</add>
  </foreignKey>
  <field>
    <name>is_domain</name>
    <title>Is Domain Setting?</title>
    <type>boolean</type>
    <default>0</default>
    <required>true</required>
    <comment>Is this setting per-domain or global?</comment>
    <add>4.1</add>
  </field>
  <field>
    <name>component_id</name>
    <title>Component ID</title>
    <type>int unsigned</type>
    <comment>Component that this menu item belongs to</comment>
    <add>4.1</add>
    <pseudoconstant>
      <table>civicrm_component</table>
      <keyColumn>id</keyColumn>
      <labelColumn>name</labelColumn>
    </pseudoconstant>
    <html>
      <type>Select</type>
      <label>Component</label>
    </html>
  </field>
  <foreignKey>
    <name>component_id</name>
    <table>civicrm_component</table>
    <key>id</key>
    <add>4.1</add>
  </foreignKey>
  <field>
    <name>created_date</name>
    <title>Setting Created Date</title>
    <type>datetime</type>
    <comment>When was the setting created</comment>
    <add>4.1</add>
  </field>
  <field>
    <name>created_id</name>
    <title>Created By Contact ID</title>
    <type>int unsigned</type>
    <comment>FK to civicrm_contact, who created this setting</comment>
    <html>
      <label>Created By</label>
    </html>
    <add>4.1</add>
  </field>
  <foreignKey>
    <name>created_id</name>
    <table>civicrm_contact</table>
    <key>id</key>
    <add>4.1</add>
    <onDelete>SET NULL</onDelete>
  </foreignKey>
  <index>
    <name>index_domain_contact_name</name>
    <fieldName>domain_id</fieldName>
    <fieldName>contact_id</fieldName>
    <fieldName>name</fieldName>
    <unique>true</unique>
    <add>4.7</add>
  </index>

</table>
