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

<table>
  <base>CRM/Contact</base>
  <class>GroupContact</class>
  <name>civicrm_group_contact</name>
  <comment>Join table sets membership for 'static' groups. Also used to store 'opt-out' entries for 'query' type groups (status = 'OUT') </comment>
  <add>1.1</add>
  <log>true</log>
  <field>
    <name>id</name>
    <type>int unsigned</type>
    <title>Group Contact ID</title>
    <required>true</required>
    <comment>primary key</comment>
    <html>
      <type>Number</type>
    </html>
    <add>1.1</add>
  </field>
  <primaryKey>
    <name>id</name>
    <autoincrement>true</autoincrement>
  </primaryKey>
  <field>
    <name>group_id</name>
    <type>int unsigned</type>
    <title>Group ID</title>
    <required>true</required>
    <comment>FK to civicrm_group</comment>
    <add>1.1</add>
    <pseudoconstant>
      <table>civicrm_group</table>
      <keyColumn>id</keyColumn>
      <labelColumn>title</labelColumn>
    </pseudoconstant>
    <html>
      <type>Select</type>
      <label>Group</label>
    </html>
  </field>
  <foreignKey>
    <name>group_id</name>
    <table>civicrm_group</table>
    <key>id</key>
    <add>1.1</add>
    <onDelete>CASCADE</onDelete>
  </foreignKey>
  <field>
    <name>contact_id</name>
    <type>int unsigned</type>
    <title>Contact ID</title>
    <required>true</required>
    <comment>FK to civicrm_contact</comment>
    <html>
      <label>Contact</label>
    </html>
    <add>1.1</add>
  </field>
  <foreignKey>
    <name>contact_id</name>
    <table>civicrm_contact</table>
    <key>id</key>
    <add>1.1</add>
    <onDelete>CASCADE</onDelete>
  </foreignKey>
  <field>
    <name>status</name>
    <type>varchar</type>
    <length>8</length>
    <title>Group Contact Status</title>
    <comment>status of contact relative to membership in group</comment>
    <pseudoconstant>
      <callback>CRM_Core_SelectValues::groupContactStatus</callback>
    </pseudoconstant>
    <add>1.1</add>
    <html>
      <type>Select</type>
    </html>
  </field>
  <field>
    <name>location_id</name>
    <type>int unsigned</type>
    <title>Location ID</title>
    <comment>Optional location to associate with this membership</comment>
    <html>
      <label>Location</label>
    </html>
    <add>1.1</add>
  </field>
  <foreignKey>
    <name>location_id</name>
    <table>civicrm_loc_block</table>
    <key>id</key>
    <add>1.1</add>
    <onDelete>SET NULL</onDelete>
  </foreignKey>
  <field>
    <name>email_id</name>
    <type>int unsigned</type>
    <title>Email ID</title>
    <comment>Optional email to associate with this membership</comment>
    <html>
      <label>Email</label>
    </html>
    <add>1.1</add>
  </field>
  <foreignKey>
    <name>email_id</name>
    <table>civicrm_email</table>
    <key>id</key>
    <add>1.1</add>
  </foreignKey>
  <index>
    <name>UI_contact_group</name>
    <fieldName>contact_id</fieldName>
    <fieldName>group_id</fieldName>
    <unique>true</unique>
    <add>1.6</add>
  </index>
</table>
