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

<table>
  <base>CRM/Core</base>
  <class>Note</class>
  <name>civicrm_note</name>
  <comment>Notes can be linked to any object in the application.</comment>
  <add>1.1</add>
  <log>true</log>
  <icon>fa-sticky-note</icon>
  <paths>
    <add>civicrm/note?reset=1&amp;action=add&amp;entity_table=[entity_table]&amp;entity_id=[entity_id]</add>
    <view>civicrm/note?reset=1&amp;action=view&amp;id=[id]</view>
    <update>civicrm/note?reset=1&amp;action=update&amp;id=[id]</update>
    <delete>civicrm/note?reset=1&amp;action=delete&amp;id=[id]</delete>
  </paths>
  <field>
    <name>id</name>
    <title>Note ID</title>
    <type>int unsigned</type>
    <required>true</required>
    <comment>Note ID</comment>
    <html>
      <type>Number</type>
    </html>
    <add>1.1</add>
  </field>
  <primaryKey>
    <name>id</name>
    <autoincrement>true</autoincrement>
  </primaryKey>
  <field>
    <name>entity_table</name>
    <title>Note Entity</title>
    <type>varchar</type>
    <length>64</length>
    <required>true</required>
    <comment>Name of table where item being referenced is stored.</comment>
    <html>
      <label>Reference Type</label>
      <type>Select</type>
    </html>
    <pseudoconstant>
      <optionGroupName>note_used_for</optionGroupName>
    </pseudoconstant>
    <add>1.1</add>
  </field>
  <field>
    <name>entity_id</name>
    <title>Note Entity ID</title>
    <type>int unsigned</type>
    <html>
      <label>Reference Item</label>
      <type>EntityRef</type>
    </html>
    <required>true</required>
    <comment>Foreign key to the referenced item.</comment>
    <add>1.1</add>
  </field>
  <dynamicForeignKey>
    <idColumn>entity_id</idColumn>
    <typeColumn>entity_table</typeColumn>
    <add>1.1</add>
  </dynamicForeignKey>
  <index>
    <name>index_entity</name>
    <fieldName>entity_table</fieldName>
    <fieldName>entity_id</fieldName>
    <add>1.1</add>
  </index>
  <field>
    <name>note</name>
    <title>Note</title>
    <type>text</type>
    <comment>Note and/or Comment.</comment>
    <html>
      <type>TextArea</type>
      <rows>4</rows>
      <cols>60</cols>
    </html>
    <import>true</import>
    <headerPattern>/Note|Comment/i</headerPattern>
    <dataPattern>//</dataPattern>
    <add>1.1</add>
  </field>
  <field>
    <name>contact_id</name>
    <title>Created By Contact ID</title>
    <type>int unsigned</type>
    <comment>FK to Contact ID creator</comment>
    <html>
      <label>Created By</label>
      <type>EntityRef</type>
    </html>
    <add>1.1</add>
  </field>
  <foreignKey>
    <name>contact_id</name>
    <table>civicrm_contact</table>
    <key>id</key>
    <add>1.1</add>
    <onDelete>SET NULL</onDelete>
  </foreignKey>
  <field>
    <name>note_date</name>
    <title>Note Date</title>
    <type>timestamp</type>
    <add>5.36</add>
    <default>CURRENT_TIMESTAMP</default>
    <comment>Date attached to the note</comment>
    <html>
     <type>Select Date</type>
     <formatType>activityDateTime</formatType>
   </html>
  </field>
  <field>
    <name>created_date</name>
    <type>timestamp</type>
    <comment>When the note was created.</comment>
    <required>true</required>
    <default>CURRENT_TIMESTAMP</default>
    <html>
      <type>Select Date</type>
      <formatType>activityDateTime</formatType>
    </html>
    <add>5.36</add>
    <readonly>true</readonly>
  </field>
  <field>
    <name>modified_date</name>
    <title>Note Modified Date</title>
    <type>timestamp</type>
    <comment>When was this note last modified/edited</comment>
    <default>CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP</default>
    <html>
      <label>Modified Date</label>
      <type>Select Date</type>
      <formatType>activityDateTime</formatType>
    </html>
    <add>1.1</add>
    <readonly>true</readonly>
  </field>
  <field>
    <name>subject</name>
    <title>Subject</title>
    <type>varchar</type>
    <length>255</length>
    <comment>subject of note description</comment>
    <html>
      <type>Text</type>
      <size>60</size>
    </html>
    <add>1.5</add>
  </field>
  <field>
    <name>privacy</name>
    <title>Privacy</title>
    <type>varchar</type>
    <length>255</length>
    <comment>Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)</comment>
    <add>3.3</add>
    <required>true</required>
    <default>0</default>
    <html>
      <type>Select</type>
    </html>
    <pseudoconstant>
      <optionGroupName>note_privacy</optionGroupName>
    </pseudoconstant>
  </field>
</table>
