<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<database name="apihub_replica_testkey" schema="public" type="PostgreSQL - 16.9">
   <sequences>
      <sequence increment="1" name="events_entity_types_id_seq" startValue="1"/>
      <sequence increment="1" name="unsorted_categories_id_seq" startValue="1"/>
   </sequences>
   <tables>
      <table name="call_statuses" remarks="Таблица статусов звонков (стандартные амо статусы звонка)" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id статуса" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="info" nullable="false" remarks="Название статуса" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="call_statuses_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="companies" remarks="Таблица компаний" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <child column="entity_id" foreignKey="companies_custom_fields_values_chained_list_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_chained_list"/>
            <child column="entity_id" foreignKey="companies_custom_fields_values_checkbox_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_checkbox"/>
            <child column="entity_id" foreignKey="companies_custom_fields_values_date_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_date"/>
            <child column="entity_id" foreignKey="companies_custom_fields_values_file_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_file"/>
            <child column="entity_id" foreignKey="companies_custom_fields_values_legal_entity_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_legal_entity"/>
            <child column="entity_id" foreignKey="companies_custom_fields_values_multitext_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_multitext"/>
            <child column="entity_id" foreignKey="companies_custom_fields_values_numeric_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_numeric"/>
            <child column="entity_id" foreignKey="companies_custom_fields_values_select_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_select"/>
            <child column="entity_id" foreignKey="companies_custom_fields_values_smart_address_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_smart_address"/>
            <child column="entity_id" foreignKey="companies_custom_fields_values_text_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_text"/>
            <child column="entity_id" foreignKey="companies_to_tags_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_to_tags"/>
            <child column="company_id" foreignKey="company_to_contacts_company_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="company_to_contacts"/>
            <child column="company_id" foreignKey="company_to_customers_company_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="company_to_customers"/>
            <child column="company_id" foreignKey="company_to_leads_company_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="company_to_leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название компании" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="false" remarks="id пользователя, ответственного за компанию" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_responsible_user_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="created_by" nullable="false" remarks="id пользователя, который создал контакт" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="updated_by" nullable="false" remarks="id пользователя, который обновил контакт" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="created_at" nullable="false" remarks="Дата создания компании" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="6" name="updated_at" nullable="false" remarks="Дата обновления компании" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="is_deleted" nullable="false" remarks="Удалена ли компания" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="8" name="closest_task_at" nullable="true" remarks="Дата ближайшей задачи к выполнению" size="29" type="timestamp" typeCode="93"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="companies_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="companies_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="companies_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="companies_updated_by_check"/>
      </table>
      <table name="companies_custom_fields_values_chained_list" remarks="Таблица значений кастомных полей связанных с каталогами и списками" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_chained_list_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_chained_lis_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="catalog_element_id" nullable="false" remarks="id объекта в каталоге или списке" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="catalog_id" nullable="false" remarks="id каталога или списка" size="10" type="int4" typeCode="4"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="companies_custom_fields_values_chained_list_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_companies_custom_fields_values_chained_list_custom_field_" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <checkConstraint constraint="((catalog_element_id &gt; 0))" name="companies_custom_fields_values_chained_catalog_element_id_check"/>
         <checkConstraint constraint="((catalog_id &gt; 0))" name="companies_custom_fields_values_chained_list_catalog_id_check"/>
      </table>
      <table name="companies_custom_fields_values_checkbox" remarks="Таблица значений кастомных полей с типом чекбокс" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_checkbox_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_checkbox_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="companies_custom_fields_values_checkbox_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_companies_custom_fields_values_checkbox_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="companies_custom_fields_values_date" remarks="Таблица значений кастомных полей для типов связанных с датой" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_date_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_date_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="2" name="value" nullable="false" remarks="Значение в формате ГГГГ-ММ-ДД ЧЧ:мм:СС" size="29" type="timestamp" typeCode="93"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="companies_custom_fields_values_date_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_companies_custom_fields_values_date_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="companies_custom_fields_values_file" remarks="Таблица значений кастомных полей для файлов" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_file_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_file_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="file_name" nullable="false" remarks="Имя файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="file_size" nullable="false" remarks="Размер файла" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="file_uuid" nullable="false" remarks="UUID файла" size="2147483647" type="uuid" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="is_deleted" nullable="false" remarks="Удален ли файл" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="version_uuid" nullable="false" remarks="Версия UUID" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="companies_custom_fields_values_file_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_companies_custom_fields_values_file_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="companies_custom_fields_values_legal_entity" remarks="Таблица значений кастомных полей с типом Юр. лицо" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_legal_entity_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_legal_entit_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="name" nullable="true" remarks="Название организации" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="entity_type" nullable="true" remarks="Тип юридического лица. 1 – Частное, 2 – Юридическое." size="5" type="int2" typeCode="5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="address" nullable="true" remarks="Адрес" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="real_address" nullable="true" remarks="Факт. адрес" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="bank_account_number" nullable="true" remarks="Рассчетный счет" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="director" nullable="true" remarks="ФИО директора организации" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="vat_id" nullable="true" remarks="ИНН организации (Россия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="tax_registration_reason_code" nullable="true" remarks="ОГРНИП (Россия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="kpp" nullable="true" remarks="КПП организации (Россия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="bank_code" nullable="true" remarks="БИК" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="bin" nullable="true" remarks="БИН организации (Казахстан)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="unp" nullable="true" remarks="УНП организации (Белоруссия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="egrpou" nullable="true" remarks="ЕГРПОУ организации (Украина)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="mfo" nullable="true" remarks="МФО организации (Украина/Узбекистан)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="oked" nullable="true" remarks="ОКЭД организации (Узбекистан)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="external_uid" nullable="true" remarks="Идентификатор внешней системы" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="companies_custom_fields_values_legal_entity_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_companies_custom_fields_values_legal_entity_custom_field_" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <checkConstraint constraint="((entity_type &gt; 0))" name="companies_custom_fields_values_legal_entity_entity_type_check"/>
      </table>
      <table name="companies_custom_fields_values_multitext" remarks="Таблица значений кастомных полей для телефона и почты" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="true" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_multitext_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="true" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_multitext_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="enum_id" nullable="false" remarks="id типа поля(Рабочий, Мобильный)" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_multitext_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_enums"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="value" nullable="false" remarks="Значение" size="2147483647" type="text" typeCode="12"/>
         <index name="index_companies_custom_fields_values_multitext_enum_id" unique="false">
            <column ascending="true" name="enum_id"/>
         </index>
         <index name="index_companies_multitext" unique="false">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="companies_custom_fields_values_numeric" remarks="Таблица значений кастомных полей с числовыми типами" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_numeric_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_numeric_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="0" type="numeric" typeCode="2"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="companies_custom_fields_values_numeric_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_companies_custom_fields_values_numeric_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="companies_custom_fields_values_select" remarks="Таблица значений кастомных полей с типами Список, Мультисписок, Переключатель (radiobutton)" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_select_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_select_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="enum_id" nullable="false" remarks="id выбранного варианта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_select_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_enums"/>
         </column>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <primaryKey column="enum_id" sequenceNumberInPK="3"/>
         <index name="companies_custom_fields_values_select_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
            <column ascending="true" name="enum_id"/>
         </index>
         <index name="index_companies_custom_fields_values_select_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_companies_custom_fields_values_select_enum_id" unique="false">
            <column ascending="true" name="enum_id"/>
         </index>
      </table>
      <table name="companies_custom_fields_values_smart_address" remarks="Таблица значений кастомных полей с типом Адрес" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_smart_address_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_smart_addre_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="enum_id" nullable="false" remarks="id типа поля (1 - Адрес, 2 - Адрес продолжение, 3 - Город, 4 - Регион, 5 - Индекс, 6 - Страна)" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_smart_address_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_enums"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="value" nullable="false" remarks="Значение" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <primaryKey column="enum_id" sequenceNumberInPK="3"/>
         <index name="companies_custom_fields_values_smart_address_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
            <column ascending="true" name="enum_id"/>
         </index>
         <index name="index_companies_custom_fields_values_multitext_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_companies_custom_fields_values_smart_address_custom_field" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_companies_custom_fields_values_smart_address_enum_id" unique="false">
            <column ascending="true" name="enum_id"/>
         </index>
      </table>
      <table name="companies_custom_fields_values_text" remarks="Таблица значений кастомных полей с текстовыми типами" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_text_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_custom_fields_values_text_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="companies_custom_fields_values_text_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_companies_custom_fields_values_text_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="companies_notes" remarks="Таблица примечаний компаний" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <child column="note_id" foreignKey="companies_notes_amomail_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_amomail_message"/>
            <child column="note_id" foreignKey="companies_notes_attachment_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_attachment"/>
            <child column="note_id" foreignKey="companies_notes_call_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_call_in"/>
            <child column="note_id" foreignKey="companies_notes_call_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_call_out"/>
            <child column="note_id" foreignKey="companies_notes_common_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_common"/>
            <child column="note_id" foreignKey="companies_notes_extended_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_extended_service_message"/>
            <child column="note_id" foreignKey="companies_notes_geolocation_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_geolocation"/>
            <child column="note_id" foreignKey="companies_notes_link_followed_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_link_followed"/>
            <child column="note_id" foreignKey="companies_notes_message_cashier_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_message_cashier"/>
            <child column="note_id" foreignKey="companies_notes_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_service_message"/>
            <child column="note_id" foreignKey="companies_notes_sms_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_sms_in"/>
            <child column="note_id" foreignKey="companies_notes_sms_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes_sms_out"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="entity_id" nullable="false" remarks="id привязанной компании" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="false" remarks="id ответственного за примечание" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="note_type" nullable="false" remarks="id типа примечания" size="5" type="int2" typeCode="5">
            <parent column="id" foreignKey="companies_notes_note_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="notes_types"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="created_at" nullable="true" remarks="Дата создания примечания" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="updated_at" nullable="false" remarks="Дата изменения примечания" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="created_by" nullable="true" remarks="id пользователя, который создал примечание" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="updated_by" nullable="false" remarks="id пользователя, который изменил примечание" size="10" type="int4" typeCode="4"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="companies_notes_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="companies_notes_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="companies_notes_id_check"/>
         <checkConstraint constraint="((responsible_user_id &gt;= 0))" name="companies_notes_responsible_user_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="companies_notes_updated_by_check"/>
      </table>
      <table name="companies_notes_amomail_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Сообщение почты Амо&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_amomail_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="access_granted" nullable="true" remarks="Доступ предоставлен" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="attach_cnt" nullable="true" remarks="Количество вложений" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="content_summary" nullable="true" remarks="Текст письма" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="delivery_status" nullable="true" remarks="Статус доставки письма" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="delivery_time" nullable="true" remarks="Дата доставки письма" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="delivery_reason" nullable="true" remarks="Причины" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="from_email" nullable="false" remarks="Почта отправителя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="from_name" nullable="true" remarks="Имя отправителя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="to_email" nullable="false" remarks="Почта получателя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="to_name" nullable="true" remarks="Имя получателя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="income" nullable="false" remarks="Входящее ли письмо" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="message_id" nullable="false" remarks="id сообщения" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="owner_id" nullable="true" remarks="id владельца (скорее всего владельца почтового ящика)" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="private" nullable="true" remarks="Приватный ли почтовый ящик Амо" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="subject" nullable="true" remarks="Тема сообщения" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="thread_id" nullable="false" remarks="id треда" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="version" nullable="false" remarks="Версия" size="10" type="int4" typeCode="4"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_amomail_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_attachment" remarks="Таблица с содержимым (params) примечаний с типом &quot;Примечание с файлом&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_attachment_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="file_name" nullable="true" remarks="Имя файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="file_uuid" nullable="true" remarks="UUID файла" size="2147483647" type="uuid" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="is_drive_attachment" nullable="false" remarks="Загружен ли файл" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="original_name" nullable="false" remarks="Исходное название файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="version_uuid" nullable="true" remarks="Версия UUID" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_attachment_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_call_in" remarks="Таблица с содержимым (params) примечаний с типом &quot;Входящий звонок&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_call_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="call_result" nullable="true" remarks="Результат звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="call_status" nullable="true" remarks="Статус звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="uniq" nullable="true" remarks="Уникальный код разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="duration" nullable="true" remarks="Длительность разговора в секундах" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="source" nullable="true" remarks="Источник звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="link" nullable="true" remarks="Ссылка на запись разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="phone" nullable="true" remarks="Телефон" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_call_in_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_call_out" remarks="Таблица с содержимым (params) примечаний с типом &quot;Исходящий звонок&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_call_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="call_result" nullable="true" remarks="Результат звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="call_status" nullable="true" remarks="Статус звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="uniq" nullable="false" remarks="Уникальный код разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="duration" nullable="true" remarks="Длительность разговора в секундах" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="source" nullable="true" remarks="Источник звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="link" nullable="true" remarks="Ссылка на запись разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="phone" nullable="true" remarks="Телефон" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_call_out_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_common" remarks="Таблица с содержимым (params) Текстовых примечаний" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_common_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_common_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_extended_service_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Расширенное системное сообщение&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_extended_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="service" nullable="true" remarks="Название сервиса" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_extended_service_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_geolocation" remarks="Таблица с содержимым (params) примечаний с типом &quot;Текстовое примечание с гео-координатами&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_geolocation_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="address" nullable="false" remarks="Адрес" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="3" name="longitude" nullable="false" remarks="Долгота" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="latitude" nullable="false" remarks="Широта" size="17" type="float8" typeCode="8"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_geolocation_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_link_followed" remarks="Таблица с содержимым (params) примечаний с типом &quot;Переход по ссылке&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_link_followed_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="url" nullable="false" remarks="URL адрес ссылки" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_link_followed_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_message_cashier" remarks="Таблица с содержимым (params) примечаний с типом &quot;Сообщение кассиру&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_message_cashier_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="status" nullable="false" remarks="Статус" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_message_cashier_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_service_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Системное сообщение&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="service" nullable="true" remarks="Название сервиса" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_service_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_sms_in" remarks="Таблица с содержимым (params) примечаний с типом &quot;Входящее SMS&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_sms_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="phone" nullable="true" remarks="Номер телефона" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_sms_in_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_sms_out" remarks="Таблица с содержимым (params) примечаний с типом &quot;Исхдящее SMS&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_notes_sms_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="phone" nullable="true" remarks="Номер телефона" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="companies_notes_sms_out_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="companies_notes_unknown" remarks="" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="entity_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="note_type" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="created_at" nullable="true" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="updated_at" nullable="false" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="created_by" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="updated_by" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="params" nullable="false" remarks="" size="2147483647" type="json" typeCode="1111"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="companies_notes_unknown_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="companies_notes_unknown_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="companies_notes_unknown_id_check"/>
         <checkConstraint constraint="((responsible_user_id &gt;= 0))" name="companies_notes_unknown_responsible_user_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="companies_notes_unknown_updated_by_check"/>
      </table>
      <table name="companies_tags" numRows="434" remarks="Таблица с тегами компаний" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id тега" size="10" type="int4" typeCode="4">
            <child column="tag_id" foreignKey="companies_to_tags_tag_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_to_tags"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название тега" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="color" nullable="true" remarks="Цвет тега" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="3" name="is_deleted" nullable="false" remarks="Удален ли тег" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="companies_tags_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="index_companies_tags_name" unique="false">
            <column ascending="true" name="name"/>
         </index>
         <checkConstraint constraint="((id &gt; 0))" name="companies_tags_id_check"/>
      </table>
      <table name="companies_to_tags" remarks="Таблица с привязкой тегов к компаниям" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_to_tags_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="tag_id" nullable="false" remarks="id тега" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="companies_to_tags_tag_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_tags"/>
         </column>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="tag_id" sequenceNumberInPK="2"/>
         <index name="companies_to_tags_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="tag_id"/>
         </index>
         <index name="index_companies_to_tags_tag_id" unique="false">
            <column ascending="true" name="tag_id"/>
         </index>
      </table>
      <table name="company_to_contacts" remarks="Таблица связей между компаниями и контактами" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="company_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="company_to_contacts_company_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="contact_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="company_to_contacts_contact_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <primaryKey column="company_id" sequenceNumberInPK="1"/>
         <primaryKey column="contact_id" sequenceNumberInPK="2"/>
         <index name="company_to_contacts_pkey" unique="true">
            <column ascending="true" name="company_id"/>
            <column ascending="true" name="contact_id"/>
         </index>
         <index name="company_to_contacts_contact_id_key" unique="true">
            <column ascending="true" name="contact_id"/>
         </index>
      </table>
      <table name="company_to_customers" remarks="Таблица связей между компаниями и покупателями" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="company_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="company_to_customers_company_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="customer_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="company_to_customers_customer_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
         </column>
         <primaryKey column="company_id" sequenceNumberInPK="1"/>
         <primaryKey column="customer_id" sequenceNumberInPK="2"/>
         <index name="company_to_customers_pkey" unique="true">
            <column ascending="true" name="company_id"/>
            <column ascending="true" name="customer_id"/>
         </index>
         <index name="company_to_customers_customer_id_key" unique="true">
            <column ascending="true" name="customer_id"/>
         </index>
      </table>
      <table name="company_to_leads" remarks="Таблица связей между компаниями и сделками" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="company_id" nullable="false" remarks="id компании" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="company_to_leads_company_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="lead_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="company_to_leads_lead_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <primaryKey column="company_id" sequenceNumberInPK="1"/>
         <primaryKey column="lead_id" sequenceNumberInPK="2"/>
         <index name="company_to_leads_pkey" unique="true">
            <column ascending="true" name="company_id"/>
            <column ascending="true" name="lead_id"/>
         </index>
         <index name="company_to_leads_lead_id_key" unique="true">
            <column ascending="true" name="lead_id"/>
         </index>
      </table>
      <table name="contacts" remarks="Таблица контактов" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <child column="contact_id" foreignKey="company_to_contacts_contact_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="company_to_contacts"/>
            <child column="entity_id" foreignKey="contacts_custom_fields_values_chained_list_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_chained_list"/>
            <child column="entity_id" foreignKey="contacts_custom_fields_values_checkbox_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_checkbox"/>
            <child column="entity_id" foreignKey="contacts_custom_fields_values_date_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_date"/>
            <child column="entity_id" foreignKey="contacts_custom_fields_values_file_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_file"/>
            <child column="entity_id" foreignKey="contacts_custom_fields_values_legal_entity_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_legal_entity"/>
            <child column="entity_id" foreignKey="contacts_custom_fields_values_multitext_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_multitext"/>
            <child column="entity_id" foreignKey="contacts_custom_fields_values_numeric_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_numeric"/>
            <child column="entity_id" foreignKey="contacts_custom_fields_values_select_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_select"/>
            <child column="entity_id" foreignKey="contacts_custom_fields_values_smart_address_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_smart_address"/>
            <child column="entity_id" foreignKey="contacts_custom_fields_values_text_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_text"/>
            <child column="entity_id" foreignKey="contacts_to_tags_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_to_tags"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название контакта" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="first_name" nullable="false" remarks="Имя контакта" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="last_name" nullable="false" remarks="Фамилия контакта" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="responsible_user_id" nullable="false" remarks="id пользователя, ответственного за контакт" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_responsible_user_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="created_by" nullable="false" remarks="id пользователя, который создал контакт" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="updated_by" nullable="false" remarks="id пользователя, который изменил контакт" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="7" name="created_at" nullable="false" remarks="Дата создания контакта" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="8" name="updated_at" nullable="false" remarks="Дата обновления контакта" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="is_deleted" nullable="false" remarks="Удален ли контакт" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="10" name="closest_task_at" nullable="true" remarks="Дата ближайшей задачи к выполнению" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="is_unsorted" nullable="false" remarks="Является ли контакт неразобранным" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="contacts_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="contacts_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="contacts_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="contacts_updated_by_check"/>
      </table>
      <table name="contacts_custom_fields_values_chained_list" remarks="Таблица значений кастомных полей связанных с каталогами и списками" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_chained_list_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_chained_list_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="catalog_element_id" nullable="false" remarks="id объекта в каталоге или списке" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="catalog_id" nullable="false" remarks="id каталога или списка" size="10" type="int4" typeCode="4"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="contacts_custom_fields_values_chained_list_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_chained_list_custom_field_i" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <checkConstraint constraint="((catalog_element_id &gt; 0))" name="contacts_custom_fields_values_chained__catalog_element_id_check"/>
         <checkConstraint constraint="((catalog_id &gt; 0))" name="contacts_custom_fields_values_chained_list_catalog_id_check"/>
      </table>
      <table name="contacts_custom_fields_values_checkbox" remarks="Таблица значений кастомных полей с типом чекбокс" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_checkbox_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_checkbox_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="contacts_custom_fields_values_checkbox_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_checkbox_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="contacts_custom_fields_values_date" remarks="Таблица значений кастомных полей для типов связанных с датой" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_date_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_date_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="2" name="value" nullable="false" remarks="Значение в формате ГГГГ-ММ-ДД ЧЧ:мм:СС" size="29" type="timestamp" typeCode="93"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="contacts_custom_fields_values_date_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_date_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="contacts_custom_fields_values_file" remarks="Таблица значений кастомных полей для файлов" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_file_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_file_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="file_name" nullable="false" remarks="Имя файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="file_size" nullable="false" remarks="Размер файла" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="file_uuid" nullable="false" remarks="UUID файла" size="2147483647" type="uuid" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="is_deleted" nullable="false" remarks="Удален ли файл" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="version_uuid" nullable="false" remarks="Версия UUID" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="contacts_custom_fields_values_file_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_file_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="contacts_custom_fields_values_legal_entity" remarks="Таблица значений кастомных полей с типом Юр. лицо" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_legal_entity_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_legal_entity_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="name" nullable="true" remarks="Название организации" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="entity_type" nullable="true" remarks="Тип юридического лица. 1 – Частное, 2 – Юридическое." size="5" type="int2" typeCode="5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="address" nullable="true" remarks="Адрес" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="real_address" nullable="true" remarks="Факт. адрес" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="bank_account_number" nullable="true" remarks="Рассчетный счет" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="director" nullable="true" remarks="ФИО директора организации" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="vat_id" nullable="true" remarks="ИНН организации (Россия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="tax_registration_reason_code" nullable="true" remarks="ОГРНИП (Россия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="kpp" nullable="true" remarks="КПП организации (Россия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="bank_code" nullable="true" remarks="БИК" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="bin" nullable="true" remarks="БИН организации (Казахстан)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="unp" nullable="true" remarks="УНП организации (Белоруссия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="egrpou" nullable="true" remarks="ЕГРПОУ организации (Украина)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="mfo" nullable="true" remarks="МФО организации (Украина/Узбекистан)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="oked" nullable="true" remarks="ОКЭД организации (Узбекистан)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="external_uid" nullable="true" remarks="Идентификатор внешней системы" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="contacts_custom_fields_values_legal_entity_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_legal_entity_custom_field_i" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <checkConstraint constraint="((entity_type &gt; 0))" name="contacts_custom_fields_values_legal_entity_entity_type_check"/>
      </table>
      <table name="contacts_custom_fields_values_multitext" remarks="Таблица значений кастомных полей для телефона и почты" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="true" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_multitext_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="true" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_multitext_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="enum_id" nullable="false" remarks="id типа поля(Рабочий, Мобильный)" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_multitext_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_enums"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="value" nullable="false" remarks="Значение" size="2147483647" type="text" typeCode="12"/>
         <index name="index_contacts_custom_fields_values_multitext_enum_id" unique="false">
            <column ascending="true" name="enum_id"/>
         </index>
         <index name="index_contacts_multitext" unique="false">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="contacts_custom_fields_values_numeric" remarks="Таблица значений кастомных полей с числовыми типами" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_numeric_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_numeric_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="0" type="numeric" typeCode="2"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="contacts_custom_fields_values_numeric_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_numeric_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="contacts_custom_fields_values_select" remarks="Таблица значений кастомных полей с типами Список, Мультисписок, Переключатель (radiobutton)" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_select_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_select_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="enum_id" nullable="false" remarks="id выбранного варианта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_select_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_enums"/>
         </column>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <primaryKey column="enum_id" sequenceNumberInPK="3"/>
         <index name="contacts_custom_fields_values_select_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
            <column ascending="true" name="enum_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_select_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_select_enum_id" unique="false">
            <column ascending="true" name="enum_id"/>
         </index>
      </table>
      <table name="contacts_custom_fields_values_smart_address" remarks="Таблица значений кастомных полей с типом Адрес" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_smart_address_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_smart_addres_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="enum_id" nullable="false" remarks="id типа поля (1 - Адрес, 2 - Адрес продолжение, 3 - Город, 4 - Регион, 5 - Индекс, 6 - Страна)" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_smart_address_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_enums"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="value" nullable="false" remarks="Значение" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <primaryKey column="enum_id" sequenceNumberInPK="3"/>
         <index name="contacts_custom_fields_values_smart_address_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
            <column ascending="true" name="enum_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_multitext_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_smart_address_custom_field_" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_smart_address_enum_id" unique="false">
            <column ascending="true" name="enum_id"/>
         </index>
      </table>
      <table name="contacts_custom_fields_values_text" remarks="Таблица значений кастомных полей с текстовыми типами" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_text_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_custom_fields_values_text_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="contacts_custom_fields_values_text_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_contacts_custom_fields_values_text_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="contacts_notes" remarks="Таблица примечаний контактов" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <child column="note_id" foreignKey="contacts_notes_amomail_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_amomail_message"/>
            <child column="note_id" foreignKey="contacts_notes_attachment_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_attachment"/>
            <child column="note_id" foreignKey="contacts_notes_call_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_call_in"/>
            <child column="note_id" foreignKey="contacts_notes_call_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_call_out"/>
            <child column="note_id" foreignKey="contacts_notes_common_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_common"/>
            <child column="note_id" foreignKey="contacts_notes_extended_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_extended_service_message"/>
            <child column="note_id" foreignKey="contacts_notes_geolocation_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_geolocation"/>
            <child column="note_id" foreignKey="contacts_notes_link_followed_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_link_followed"/>
            <child column="note_id" foreignKey="contacts_notes_message_cashier_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_message_cashier"/>
            <child column="note_id" foreignKey="contacts_notes_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_service_message"/>
            <child column="note_id" foreignKey="contacts_notes_sms_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_sms_in"/>
            <child column="note_id" foreignKey="contacts_notes_sms_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes_sms_out"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="entity_id" nullable="false" remarks="id привязанного контакта" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="false" remarks="id ответственного за примечание" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="note_type" nullable="false" remarks="id типа примечания" size="5" type="int2" typeCode="5">
            <parent column="id" foreignKey="contacts_notes_note_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="notes_types"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="created_at" nullable="true" remarks="Дата создания примечания" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="updated_at" nullable="false" remarks="Дата изменения примечания" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="created_by" nullable="true" remarks="id пользователя, который создал примечание" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="updated_by" nullable="false" remarks="id пользователя, который изменил примечание" size="10" type="int4" typeCode="4"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="contacts_notes_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="contacts_notes_id_check"/>
         <checkConstraint constraint="((responsible_user_id &gt;= 0))" name="contacts_notes_responsible_user_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="contacts_notes_updated_by_check"/>
      </table>
      <table name="contacts_notes_amomail_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Сообщение почты Амо&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_amomail_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="access_granted" nullable="true" remarks="Доступ предоставлен" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="attach_cnt" nullable="true" remarks="Количество вложений" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="content_summary" nullable="true" remarks="Текст письма" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="delivery_status" nullable="true" remarks="Статус доставки письма" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="delivery_time" nullable="true" remarks="Дата доставки письма" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="delivery_reason" nullable="true" remarks="Причины" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="from_email" nullable="false" remarks="Почта отправителя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="from_name" nullable="true" remarks="Имя отправителя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="to_email" nullable="false" remarks="Почта получателя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="to_name" nullable="true" remarks="Имя получателя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="income" nullable="false" remarks="Входящее ли письмо" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="message_id" nullable="false" remarks="id сообщения" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="owner_id" nullable="true" remarks="id владельца (скорее всего владельца почтового ящика)" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="private" nullable="true" remarks="Приватный ли почтовый ящик Амо" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="subject" nullable="true" remarks="Тема сообщения" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="thread_id" nullable="false" remarks="id треда" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="version" nullable="false" remarks="Версия" size="10" type="int4" typeCode="4"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_amomail_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_attachment" remarks="Таблица с содержимым (params) примечаний с типом &quot;Примечание с файлом&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_attachment_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="file_name" nullable="true" remarks="Имя файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="file_uuid" nullable="true" remarks="UUID файла" size="2147483647" type="uuid" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="is_drive_attachment" nullable="false" remarks="Загружен ли файл" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="original_name" nullable="false" remarks="Исходное название файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="version_uuid" nullable="true" remarks="Версия UUID" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_attachment_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_call_in" remarks="Таблица с содержимым (params) примечаний с типом &quot;Входящий звонок&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_call_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="call_result" nullable="true" remarks="Результат звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="call_status" nullable="true" remarks="Статус звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="uniq" nullable="true" remarks="Уникальный код разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="duration" nullable="true" remarks="Длительность разговора в секундах" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="source" nullable="true" remarks="Источник звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="link" nullable="true" remarks="Ссылка на запись разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="phone" nullable="true" remarks="Телефон" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_call_in_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_call_out" remarks="Таблица с содержимым (params) примечаний с типом &quot;Исходящий звонок&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_call_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="call_result" nullable="true" remarks="Результат звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="call_status" nullable="true" remarks="Статус звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="uniq" nullable="false" remarks="Уникальный код разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="duration" nullable="true" remarks="Длительность разговора в секундах" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="source" nullable="true" remarks="Источник звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="link" nullable="true" remarks="Ссылка на запись разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="phone" nullable="true" remarks="Телефон" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_call_out_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_common" remarks="Таблица с содержимым (params) Текстовых примечаний" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_common_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_common_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_extended_service_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Расширенное системное сообщение&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_extended_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="service" nullable="true" remarks="Название сервиса" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_extended_service_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_geolocation" remarks="Таблица с содержимым (params) примечаний с типом &quot;Текстовое примечание с гео-координатами&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_geolocation_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="address" nullable="false" remarks="Адрес" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="3" name="longitude" nullable="false" remarks="Долгота" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="latitude" nullable="false" remarks="Широта" size="17" type="float8" typeCode="8"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_geolocation_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_link_followed" remarks="Таблица с содержимым (params) примечаний с типом &quot;Переход по ссылке&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_link_followed_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="url" nullable="false" remarks="URL адрес ссылки" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_link_followed_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_message_cashier" remarks="Таблица с содержимым (params) примечаний с типом &quot;Сообщение кассиру&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_message_cashier_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="status" nullable="false" remarks="Статус" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_message_cashier_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_service_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Системное сообщение&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="service" nullable="true" remarks="Название сервиса" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_service_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_sms_in" remarks="Таблица с содержимым (params) примечаний с типом &quot;Входящее SMS&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_sms_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="phone" nullable="true" remarks="Номер телефона" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_sms_in_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_sms_out" remarks="Таблица с содержимым (params) примечаний с типом &quot;Исхдящее SMS&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_notes_sms_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="phone" nullable="true" remarks="Номер телефона" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_sms_out_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="contacts_notes_unknown" remarks="" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="entity_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="note_type" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="created_at" nullable="true" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="updated_at" nullable="false" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="created_by" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="updated_by" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="params" nullable="false" remarks="" size="2147483647" type="json" typeCode="1111"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="contacts_notes_unknown_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="contacts_notes_unknown_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="contacts_notes_unknown_id_check"/>
         <checkConstraint constraint="((responsible_user_id &gt;= 0))" name="contacts_notes_unknown_responsible_user_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="contacts_notes_unknown_updated_by_check"/>
      </table>
      <table name="contacts_tags" numRows="434" remarks="Таблица с тегами контактов" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id тега" size="10" type="int4" typeCode="4">
            <child column="tag_id" foreignKey="contacts_to_tags_tag_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_to_tags"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название тега" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="color" nullable="true" remarks="Цвет тега" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="3" name="is_deleted" nullable="false" remarks="Удален ли тег" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="contacts_tags_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="index_contacts_tags_name" unique="false">
            <column ascending="true" name="name"/>
         </index>
         <checkConstraint constraint="((id &gt; 0))" name="contacts_tags_id_check"/>
      </table>
      <table name="contacts_to_customers" remarks="Таблица связей между контактами и покупателями" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="contact_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="customer_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="is_main" nullable="true" remarks="Является ли этот контакт главным для покупателя" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="contact_id" sequenceNumberInPK="1"/>
         <primaryKey column="customer_id" sequenceNumberInPK="2"/>
         <index name="contacts_to_customers_pkey" unique="true">
            <column ascending="true" name="contact_id"/>
            <column ascending="true" name="customer_id"/>
         </index>
      </table>
      <table name="contacts_to_leads" remarks="Таблица связей между контактами и сделками" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="contact_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="lead_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="is_main" nullable="true" remarks="Является ли этот контакт главным для покупателя" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="contact_id" sequenceNumberInPK="1"/>
         <primaryKey column="lead_id" sequenceNumberInPK="2"/>
         <index name="contacts_to_leads_pkey" unique="true">
            <column ascending="true" name="contact_id"/>
            <column ascending="true" name="lead_id"/>
         </index>
      </table>
      <table name="contacts_to_tags" remarks="Таблица с привязкой тегов к контактам" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id контакта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_to_tags_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="tag_id" nullable="false" remarks="id тега" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="contacts_to_tags_tag_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_tags"/>
         </column>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="tag_id" sequenceNumberInPK="2"/>
         <index name="contacts_to_tags_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="tag_id"/>
         </index>
         <index name="index_contacts_to_tags_tag_id" unique="false">
            <column ascending="true" name="tag_id"/>
         </index>
      </table>
      <table name="custom_fields" numRows="332" remarks="Таблица кастомных полей аккаунта" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <child column="custom_field_id" foreignKey="companies_custom_fields_values_chained_lis_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_chained_list"/>
            <child column="custom_field_id" foreignKey="companies_custom_fields_values_checkbox_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_checkbox"/>
            <child column="custom_field_id" foreignKey="companies_custom_fields_values_date_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_date"/>
            <child column="custom_field_id" foreignKey="companies_custom_fields_values_file_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_file"/>
            <child column="custom_field_id" foreignKey="companies_custom_fields_values_legal_entit_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_legal_entity"/>
            <child column="custom_field_id" foreignKey="companies_custom_fields_values_multitext_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_multitext"/>
            <child column="custom_field_id" foreignKey="companies_custom_fields_values_numeric_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_numeric"/>
            <child column="custom_field_id" foreignKey="companies_custom_fields_values_select_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_select"/>
            <child column="custom_field_id" foreignKey="companies_custom_fields_values_smart_addre_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_smart_address"/>
            <child column="custom_field_id" foreignKey="companies_custom_fields_values_text_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_text"/>
            <child column="custom_field_id" foreignKey="contacts_custom_fields_values_chained_list_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_chained_list"/>
            <child column="custom_field_id" foreignKey="contacts_custom_fields_values_checkbox_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_checkbox"/>
            <child column="custom_field_id" foreignKey="contacts_custom_fields_values_date_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_date"/>
            <child column="custom_field_id" foreignKey="contacts_custom_fields_values_file_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_file"/>
            <child column="custom_field_id" foreignKey="contacts_custom_fields_values_legal_entity_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_legal_entity"/>
            <child column="custom_field_id" foreignKey="contacts_custom_fields_values_multitext_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_multitext"/>
            <child column="custom_field_id" foreignKey="contacts_custom_fields_values_numeric_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_numeric"/>
            <child column="custom_field_id" foreignKey="contacts_custom_fields_values_select_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_select"/>
            <child column="custom_field_id" foreignKey="contacts_custom_fields_values_smart_addres_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_smart_address"/>
            <child column="custom_field_id" foreignKey="contacts_custom_fields_values_text_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_text"/>
            <child column="custom_field_id" foreignKey="custom_fields_enums_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_enums"/>
            <child column="custom_field_id" foreignKey="customers_custom_fields_values_chained_lis_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_chained_list"/>
            <child column="custom_field_id" foreignKey="customers_custom_fields_values_checkbox_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_checkbox"/>
            <child column="custom_field_id" foreignKey="customers_custom_fields_values_date_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_date"/>
            <child column="custom_field_id" foreignKey="customers_custom_fields_values_file_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_file"/>
            <child column="custom_field_id" foreignKey="customers_custom_fields_values_numeric_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_numeric"/>
            <child column="custom_field_id" foreignKey="customers_custom_fields_values_select_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_select"/>
            <child column="custom_field_id" foreignKey="customers_custom_fields_values_text_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_text"/>
            <child column="custom_field_id" foreignKey="leads_custom_fields_values_chained_list_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_chained_list"/>
            <child column="custom_field_id" foreignKey="leads_custom_fields_values_checkbox_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_checkbox"/>
            <child column="custom_field_id" foreignKey="leads_custom_fields_values_date_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_date"/>
            <child column="custom_field_id" foreignKey="leads_custom_fields_values_file_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_file"/>
            <child column="custom_field_id" foreignKey="leads_custom_fields_values_legal_entity_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_legal_entity"/>
            <child column="custom_field_id" foreignKey="leads_custom_fields_values_numeric_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_numeric"/>
            <child column="custom_field_id" foreignKey="leads_custom_fields_values_select_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_select"/>
            <child column="custom_field_id" foreignKey="leads_custom_fields_values_smart_address_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_smart_address"/>
            <child column="custom_field_id" foreignKey="leads_custom_fields_values_text_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_text"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название кастомного поля" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="code" nullable="true" remarks="Код кастомного поля" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="type_id" nullable="false" remarks="Id типа кастомного поля (см. custom_fields_types)" size="5" type="int2" typeCode="5">
            <parent column="id" foreignKey="custom_fields_type_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_types"/>
         </column>
         <column autoUpdated="false" defaultValue="false" digits="0" id="4" name="is_deleted" nullable="false" remarks="Удалено ли кастомное поле" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="custom_fields_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((id &gt; 0))" name="custom_fields_id_check"/>
      </table>
      <table name="custom_fields_enums" numRows="1070" remarks="Таблица вариантов выбора кастомных полей (enum-ов)" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id варианта выбора" size="10" type="int4" typeCode="4">
            <child column="enum_id" foreignKey="companies_custom_fields_values_multitext_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_multitext"/>
            <child column="enum_id" foreignKey="companies_custom_fields_values_select_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_select"/>
            <child column="enum_id" foreignKey="companies_custom_fields_values_smart_address_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_custom_fields_values_smart_address"/>
            <child column="enum_id" foreignKey="contacts_custom_fields_values_multitext_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_multitext"/>
            <child column="enum_id" foreignKey="contacts_custom_fields_values_select_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_select"/>
            <child column="enum_id" foreignKey="contacts_custom_fields_values_smart_address_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_custom_fields_values_smart_address"/>
            <child column="enum_id" foreignKey="customers_custom_fields_values_select_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_select"/>
            <child column="enum_id" foreignKey="leads_custom_fields_values_select_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_select"/>
            <child column="enum_id" foreignKey="leads_custom_fields_values_smart_address_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_smart_address"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="code" nullable="true" remarks="Код варианта выбора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение варианта выбора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="custom_field_id" nullable="false" remarks="id кастомного поля для данного варианта выбора" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="custom_fields_enums_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="false" digits="0" id="4" name="is_deleted" nullable="false" remarks="Удален ли вариант выбора" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="custom_fields_enums_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="index_custom_fields_enums_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_custom_fields_enums_value" unique="false">
            <column ascending="true" name="value"/>
         </index>
         <checkConstraint constraint="((id &gt; 0))" name="custom_fields_enums_id_check"/>
      </table>
      <table name="custom_fields_types" remarks="Таблица типов кастомных полей" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id типа (совпадает с амо)" size="5" type="int2" typeCode="5">
            <child column="type_id" foreignKey="custom_fields_type_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="table_name" nullable="false" remarks="часть названия таблицы, в которой мы храним данные по данному типу кастомного поля" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="type" nullable="false" remarks="название типа (совпадает с амо)" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="custom_fields_types_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="custom_fields_types_type_key" unique="true">
            <column ascending="true" name="type"/>
         </index>
         <checkConstraint constraint="((id &gt; 0))" name="custom_fields_types_id_check"/>
      </table>
      <table name="customers" remarks="Таблица покупателей" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <child column="customer_id" foreignKey="company_to_customers_customer_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="company_to_customers"/>
            <child column="entity_id" foreignKey="customers_custom_fields_values_chained_list_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_chained_list"/>
            <child column="entity_id" foreignKey="customers_custom_fields_values_checkbox_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_checkbox"/>
            <child column="entity_id" foreignKey="customers_custom_fields_values_date_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_date"/>
            <child column="entity_id" foreignKey="customers_custom_fields_values_file_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_file"/>
            <child column="entity_id" foreignKey="customers_custom_fields_values_numeric_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_numeric"/>
            <child column="entity_id" foreignKey="customers_custom_fields_values_select_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_select"/>
            <child column="entity_id" foreignKey="customers_custom_fields_values_text_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_custom_fields_values_text"/>
            <child column="entity_id" foreignKey="customers_to_segments_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_to_segments"/>
            <child column="entity_id" foreignKey="customers_to_tags_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_to_tags"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название покупателя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="false" remarks="id пользователя, ответственного за покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_responsible_user_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="status_id" nullable="false" remarks="ID статуса покупателя в аккаунте" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="purchases_count" nullable="false" remarks="Количество покупок" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="periodicity" nullable="false" remarks="Периодичность" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="6" name="next_date" nullable="true" remarks="Ожидаемая дата следующей покупки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="next_price" nullable="true" remarks="Ожидаемая сумма покупки" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="ltv" nullable="true" remarks="Сумма покупок" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="labor_cost" nullable="false" remarks="Стоимость труда" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="average_check" nullable="true" remarks="Средний размер покупки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="is_deleted" nullable="false" remarks="Удален ли покупатель" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="12" name="closest_task_at" nullable="true" remarks="Дата ближайшей задачи к выполнению" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="created_at" nullable="false" remarks="Дата создания покупателя" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="14" name="updated_at" nullable="false" remarks="Дата изменения покупателя" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="created_by" nullable="false" remarks="id пользователя, создавшего покупателя" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="updated_by" nullable="false" remarks="id пользователя, изменившего покупателя" size="10" type="int4" typeCode="4"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="customers_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="customers_created_by_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="customers_updated_by_check"/>
      </table>
      <table name="customers_custom_fields_values_chained_list" remarks="Таблица значений кастомных полей связанных с каталогами и списками" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_chained_list_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_chained_lis_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="catalog_element_id" nullable="false" remarks="id объекта в каталоге или списке" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="catalog_id" nullable="false" remarks="id каталога или списка" size="10" type="int4" typeCode="4"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="customers_custom_fields_values_chained_list_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_customers_custom_fields_values_chained_list_custom_field_" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <checkConstraint constraint="((catalog_element_id &gt; 0))" name="customers_custom_fields_values_chained_catalog_element_id_check"/>
         <checkConstraint constraint="((catalog_id &gt; 0))" name="customers_custom_fields_values_chained_list_catalog_id_check"/>
      </table>
      <table name="customers_custom_fields_values_checkbox" remarks="Таблица значений кастомных полей с типом чекбокс" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_checkbox_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_checkbox_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="customers_custom_fields_values_checkbox_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_customers_custom_fields_values_checkbox_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="customers_custom_fields_values_date" remarks="Таблица значений кастомных полей для типов связанных с датой" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_date_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_date_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="2" name="value" nullable="false" remarks="Значение в формате ГГГГ-ММ-ДД ЧЧ:мм:СС" size="29" type="timestamp" typeCode="93"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="customers_custom_fields_values_date_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_customers_custom_fields_values_date_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="customers_custom_fields_values_file" remarks="Таблица значений кастомных полей для файлов" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_file_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_file_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="file_name" nullable="false" remarks="Имя файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="file_size" nullable="false" remarks="Размер файла" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="file_uuid" nullable="false" remarks="UUID файла" size="2147483647" type="uuid" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="is_deleted" nullable="false" remarks="Удален ли файл" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="version_uuid" nullable="false" remarks="Версия UUID" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="customers_custom_fields_values_file_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_customers_custom_fields_values_file_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="customers_custom_fields_values_numeric" remarks="Таблица значений кастомных полей с числовыми типами" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_numeric_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_numeric_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="0" type="numeric" typeCode="2"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="customers_custom_fields_values_numeric_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_customers_custom_fields_values_numeric_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="customers_custom_fields_values_select" remarks="Таблица значений кастомных полей с типами Список, Мультисписок, Переключатель (radiobutton)" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_select_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_select_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="enum_id" nullable="false" remarks="id выбранного варианта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_select_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_enums"/>
         </column>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <primaryKey column="enum_id" sequenceNumberInPK="3"/>
         <index name="customers_custom_fields_values_select_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
            <column ascending="true" name="enum_id"/>
         </index>
         <index name="index_customers_custom_fields_values_select_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_customers_custom_fields_values_select_enum_id" unique="false">
            <column ascending="true" name="enum_id"/>
         </index>
      </table>
      <table name="customers_custom_fields_values_text" remarks="Таблица значений кастомных полей с текстовыми типами" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_text_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_custom_fields_values_text_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="customers_custom_fields_values_text_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_customers_custom_fields_values_text_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="customers_notes" remarks="Таблица примечаний покупателей" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <child column="note_id" foreignKey="customers_notes_amomail_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_amomail_message"/>
            <child column="note_id" foreignKey="customers_notes_attachment_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_attachment"/>
            <child column="note_id" foreignKey="customers_notes_call_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_call_in"/>
            <child column="note_id" foreignKey="customers_notes_call_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_call_out"/>
            <child column="note_id" foreignKey="customers_notes_common_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_common"/>
            <child column="note_id" foreignKey="customers_notes_extended_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_extended_service_message"/>
            <child column="note_id" foreignKey="customers_notes_geolocation_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_geolocation"/>
            <child column="note_id" foreignKey="customers_notes_link_followed_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_link_followed"/>
            <child column="note_id" foreignKey="customers_notes_message_cashier_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_message_cashier"/>
            <child column="note_id" foreignKey="customers_notes_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_service_message"/>
            <child column="note_id" foreignKey="customers_notes_sms_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_sms_in"/>
            <child column="note_id" foreignKey="customers_notes_sms_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_sms_out"/>
            <child column="note_id" foreignKey="customers_notes_transaction_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes_transaction"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="entity_id" nullable="false" remarks="id привязанного покупателя" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="false" remarks="id ответственного за примечание" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="note_type" nullable="false" remarks="id типа примечания" size="5" type="int2" typeCode="5">
            <parent column="id" foreignKey="customers_notes_note_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="notes_types"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="created_at" nullable="true" remarks="Дата создания примечания" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="updated_at" nullable="false" remarks="Дата изменения примечания" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="created_by" nullable="true" remarks="id пользователя, который создал примечание" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="updated_by" nullable="false" remarks="id пользователя, который изменил примечание" size="10" type="int4" typeCode="4"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="customers_notes_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="customers_notes_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="customers_notes_id_check"/>
         <checkConstraint constraint="((responsible_user_id &gt;= 0))" name="customers_notes_responsible_user_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="customers_notes_updated_by_check"/>
      </table>
      <table name="customers_notes_amomail_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Сообщение почты Амо&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_amomail_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="access_granted" nullable="true" remarks="Доступ предоставлен" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="attach_cnt" nullable="true" remarks="Количество вложений" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="content_summary" nullable="true" remarks="Текст письма" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="delivery_status" nullable="true" remarks="Статус доставки письма" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="delivery_time" nullable="true" remarks="Дата доставки письма" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="delivery_reason" nullable="true" remarks="Причины" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="from_email" nullable="false" remarks="Почта отправителя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="from_name" nullable="true" remarks="Имя отправителя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="to_email" nullable="false" remarks="Почта получателя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="to_name" nullable="true" remarks="Имя получателя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="income" nullable="false" remarks="Входящее ли письмо" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="message_id" nullable="false" remarks="id сообщения" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="owner_id" nullable="true" remarks="id владельца (скорее всего владельца почтового ящика)" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="private" nullable="true" remarks="Приватный ли почтовый ящик Амо" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="subject" nullable="true" remarks="Тема сообщения" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="thread_id" nullable="false" remarks="id треда" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="version" nullable="false" remarks="Версия" size="10" type="int4" typeCode="4"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_amomail_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_attachment" remarks="Таблица с содержимым (params) примечаний с типом &quot;Примечание с файлом&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_attachment_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="file_name" nullable="true" remarks="Имя файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="file_uuid" nullable="true" remarks="UUID файла" size="2147483647" type="uuid" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="is_drive_attachment" nullable="false" remarks="Загружен ли файл" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="original_name" nullable="false" remarks="Исходное название файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="version_uuid" nullable="true" remarks="Версия UUID" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_attachment_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_call_in" remarks="Таблица с содержимым (params) примечаний с типом &quot;Входящий звонок&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_call_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="call_result" nullable="true" remarks="Результат звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="call_status" nullable="true" remarks="Статус звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="uniq" nullable="true" remarks="Уникальный код разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="duration" nullable="true" remarks="Длительность разговора в секундах" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="source" nullable="true" remarks="Источник звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="link" nullable="true" remarks="Ссылка на запись разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="phone" nullable="true" remarks="Телефон" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_call_in_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_call_out" remarks="Таблица с содержимым (params) примечаний с типом &quot;Исходящий звонок&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_call_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="call_result" nullable="true" remarks="Результат звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="call_status" nullable="true" remarks="Статус звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="uniq" nullable="false" remarks="Уникальный код разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="duration" nullable="true" remarks="Длительность разговора в секундах" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="source" nullable="true" remarks="Источник звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="link" nullable="true" remarks="Ссылка на запись разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="phone" nullable="true" remarks="Телефон" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_call_out_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_common" remarks="Таблица с содержимым (params) Текстовых примечаний" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_common_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_common_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_extended_service_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Расширенное системное сообщение&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_extended_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="service" nullable="true" remarks="Название сервиса" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_extended_service_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_geolocation" remarks="Таблица с содержимым (params) примечаний с типом &quot;Текстовое примечание с гео-координатами&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_geolocation_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="address" nullable="false" remarks="Адрес" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="3" name="longitude" nullable="false" remarks="Долгота" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="latitude" nullable="false" remarks="Широта" size="17" type="float8" typeCode="8"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_geolocation_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_link_followed" remarks="Таблица с содержимым (params) примечаний с типом &quot;Переход по ссылке&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_link_followed_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="url" nullable="false" remarks="URL адрес ссылки" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_link_followed_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_message_cashier" remarks="Таблица с содержимым (params) примечаний с типом &quot;Сообщение кассиру&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_message_cashier_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="status" nullable="false" remarks="Статус" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_message_cashier_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_service_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Системное сообщение&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="service" nullable="true" remarks="Название сервиса" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_service_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_sms_in" remarks="Таблица с содержимым (params) примечаний с типом &quot;Входящее SMS&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_sms_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="phone" nullable="true" remarks="Номер телефона" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_sms_in_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_sms_out" remarks="Таблица с содержимым (params) примечаний с типом &quot;Исхдящее SMS&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_sms_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="phone" nullable="true" remarks="Номер телефона" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_sms_out_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_transaction" remarks="Таблица с содержимым (params) примечаний с типом &quot;Транзакция&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_notes_transaction_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="transaction_id" nullable="false" remarks="id транзакции" size="10" type="int4" typeCode="4"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="customers_notes_transaction_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="customers_notes_unknown" remarks="" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="entity_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="note_type" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="created_at" nullable="true" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="updated_at" nullable="false" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="created_by" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="updated_by" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="params" nullable="false" remarks="" size="2147483647" type="json" typeCode="1111"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="customers_notes_unknown_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="customers_notes_unknown_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="customers_notes_unknown_id_check"/>
         <checkConstraint constraint="((responsible_user_id &gt;= 0))" name="customers_notes_unknown_responsible_user_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="customers_notes_unknown_updated_by_check"/>
      </table>
      <table name="customers_tags" remarks="Таблица с тегами покупателей" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id тега" size="10" type="int4" typeCode="4">
            <child column="tag_id" foreignKey="customers_to_tags_tag_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_to_tags"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название тега" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="color" nullable="true" remarks="Цвет тега" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="3" name="is_deleted" nullable="false" remarks="Удален ли тег" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="customers_tags_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="index_customers_tags_name" unique="false">
            <column ascending="true" name="name"/>
         </index>
         <checkConstraint constraint="((id &gt; 0))" name="customers_tags_id_check"/>
      </table>
      <table name="customers_to_segments" remarks="Таблица с привязкой сегментов к покупатетелям" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_to_segments_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="segment_id" nullable="false" remarks="id сегмента" size="10" type="int4" typeCode="4"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="segment_id" sequenceNumberInPK="2"/>
         <index name="customers_to_segments_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="segment_id"/>
         </index>
      </table>
      <table name="customers_to_tags" remarks="Таблица с привязкой тегов к покупатетелям" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id покупателя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_to_tags_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="tag_id" nullable="false" remarks="id тега" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="customers_to_tags_tag_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_tags"/>
         </column>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="tag_id" sequenceNumberInPK="2"/>
         <index name="customers_to_tags_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="tag_id"/>
         </index>
         <index name="index_customers_to_tags_tag_id" unique="false">
            <column ascending="true" name="tag_id"/>
         </index>
      </table>
      <table name="event_types" numRows="53" remarks="Таблица с типами событий" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id типа" size="5" type="int2" typeCode="5">
            <child column="event_type" foreignKey="events_new_event_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="events_new"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="type" nullable="true" remarks="Название типа" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="obj_key" nullable="true" remarks="Ключ объекта данных" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="first_value_key" nullable="true" remarks="Название ключа первого параметра" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="first_value_type" nullable="true" remarks="Тип первого параметра" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="second_value_key" nullable="true" remarks="Название ключа второго параметра" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="second_value_type" nullable="true" remarks="Тип второго параметра" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="event_types_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="events_custom_field_values_changed" remarks="" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="2147483647" type="text" typeCode="12">
            <parent column="id" foreignKey="events_custom_field_values_changed_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="events_new"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="sort" nullable="false" remarks="" size="5" type="int2" typeCode="5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="field_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="before_enum_id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="before_text" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="before_timestamp" nullable="true" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="before_subtype_id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="after_enum_id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="after_text" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="9" name="after_timestamp" nullable="true" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="after_subtype_id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <primaryKey column="sort" sequenceNumberInPK="2"/>
         <index name="events_custom_field_values_changed_pkey" unique="true">
            <column ascending="true" name="id"/>
            <column ascending="true" name="sort"/>
         </index>
      </table>
      <table name="events_entity_types" remarks="" schema="public" type="TABLE">
         <column autoUpdated="true" defaultValue="nextval('events_entity_types_id_seq'::regclass)" digits="0" id="0" name="id" nullable="false" remarks="" size="5" type="smallserial" typeCode="5">
            <child column="entity_type" foreignKey="events_new_entity_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="events_new"/>
            <child column="entity_type" foreignKey="unknown_events_entity_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="unknown_events"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="type" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="events_entity_types_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="events_entity_types_type_key" unique="true">
            <column ascending="true" name="type"/>
         </index>
      </table>
      <table name="events_new" remarks="" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="2147483647" type="text" typeCode="12">
            <child column="id" foreignKey="events_custom_field_values_changed_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="events_custom_field_values_changed"/>
            <child column="id" foreignKey="events_values_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="events_values"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="1" name="created_at" nullable="false" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="created_by" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="entity_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="entity_type" nullable="false" remarks="" size="5" type="int2" typeCode="5">
            <parent column="id" foreignKey="events_new_entity_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="events_entity_types"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="event_type" nullable="false" remarks="" size="5" type="int2" typeCode="5">
            <parent column="id" foreignKey="events_new_event_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="event_types"/>
         </column>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="events_new_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="idx_events_created_at" unique="false">
            <column ascending="true" name="created_at"/>
         </index>
         <index name="idx_events_entity_types" unique="false">
            <column ascending="true" name="entity_type"/>
            <column ascending="true" name="entity_id"/>
         </index>
         <index name="idx_events_types" unique="false">
            <column ascending="true" name="event_type"/>
            <column ascending="true" name="entity_id"/>
         </index>
      </table>
      <table name="events_values" remarks="" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="2147483647" type="text" typeCode="12">
            <parent column="id" foreignKey="events_values_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="events_new"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="sort" nullable="false" remarks="" size="5" type="int2" typeCode="5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="first_value_before_text" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="first_value_before_int" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="first_value_before_timestamp" nullable="true" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="first_value_after_text" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="first_value_after_int" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="7" name="first_value_after_timestamp" nullable="true" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="second_value_before_int" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="second_value_after_int" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <primaryKey column="sort" sequenceNumberInPK="2"/>
         <index name="events_values_pkey" unique="true">
            <column ascending="true" name="id"/>
            <column ascending="true" name="sort"/>
         </index>
      </table>
      <table name="leads" remarks="Таблица сделок" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <child column="lead_id" foreignKey="company_to_leads_lead_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="company_to_leads"/>
            <child column="entity_id" foreignKey="leads_custom_fields_values_chained_list_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_chained_list"/>
            <child column="entity_id" foreignKey="leads_custom_fields_values_checkbox_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_checkbox"/>
            <child column="entity_id" foreignKey="leads_custom_fields_values_date_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_date"/>
            <child column="entity_id" foreignKey="leads_custom_fields_values_file_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_file"/>
            <child column="entity_id" foreignKey="leads_custom_fields_values_legal_entity_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_legal_entity"/>
            <child column="entity_id" foreignKey="leads_custom_fields_values_numeric_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_numeric"/>
            <child column="entity_id" foreignKey="leads_custom_fields_values_select_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_select"/>
            <child column="entity_id" foreignKey="leads_custom_fields_values_smart_address_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_smart_address"/>
            <child column="entity_id" foreignKey="leads_custom_fields_values_text_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_custom_fields_values_text"/>
            <child column="entity_id" foreignKey="leads_to_tags_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_to_tags"/>
            <child column="lead_id" foreignKey="unsorted_lead_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название сделки" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="price" nullable="false" remarks="Бюджет сделки" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="responsible_user_id" nullable="false" remarks="id пользователя, ответственного за сделку" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_responsible_user_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="status_id" nullable="true" remarks="id статуса" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_status_id_pipeline_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="statuses"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="pipeline_id" nullable="true" remarks="id воронки продаж" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_pipeline_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="pipelines"/>
            <parent column="pipeline_id" foreignKey="leads_status_id_pipeline_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="statuses"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="loss_reason_id" nullable="true" remarks="id причины отказа" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="source_id" nullable="true" remarks="id источника сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="created_by" nullable="false" remarks="id пользователя, который создал сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="updated_by" nullable="false" remarks="id пользователя, который изменил сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="10" name="closed_at" nullable="true" remarks="Дата закрытия сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="11" name="created_at" nullable="false" remarks="Дата создания сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="12" name="updated_at" nullable="false" remarks="Дата изменения сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="closest_task_at" nullable="true" remarks="Дата ближайшей задачи к выполнению" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="is_deleted" nullable="false" remarks="Удалена ли сделка" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="score" nullable="true" remarks="Скоринг сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="labor_cost" nullable="true" remarks="Тип поля &quot;стоимость труда&quot; показывает сколько времени было затрачено на работу со сделкой. Время исчисления в секундах" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="is_price_modified_by_robot" nullable="true" remarks="Изменен ли в последний раз бюджет сделки роботом" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="18" name="is_price_computed" nullable="true" remarks="Был ли бюджет вычеслен по формуле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="19" name="price_with_minor_units" nullable="true" remarks="Бюджет сделки в минорных единицах валюты (например, в копейках)" size="19" type="int8" typeCode="-5"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="leads_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="index_leads_pipeline_id" unique="false">
            <column ascending="true" name="pipeline_id"/>
         </index>
         <index name="index_leads_statuses" unique="false">
            <column ascending="true" name="status_id"/>
            <column ascending="true" name="closed_at"/>
            <column ascending="true" name="created_at"/>
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="leads_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="leads_id_check"/>
         <checkConstraint constraint="((labor_cost &gt;= 0))" name="leads_labor_cost_check"/>
         <checkConstraint constraint="((price &gt;= 0))" name="leads_price_check"/>
         <checkConstraint constraint="((price_with_minor_units &gt;= 0))" name="leads_price_with_minor_units_check"/>
         <checkConstraint constraint="((source_id &gt; 0))" name="leads_source_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="leads_updated_by_check"/>
      </table>
      <table name="leads_custom_fields_values_chained_list" remarks="Таблица значений кастомных полей связанных с каталогами и списками" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_chained_list_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_chained_list_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="catalog_element_id" nullable="false" remarks="id объекта в каталоге или списке" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="catalog_id" nullable="false" remarks="id каталога или списка" size="10" type="int4" typeCode="4"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="leads_custom_fields_values_chained_list_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_leads_custom_fields_values_chained_list_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <checkConstraint constraint="((catalog_element_id &gt; 0))" name="leads_custom_fields_values_chained_lis_catalog_element_id_check"/>
         <checkConstraint constraint="((catalog_id &gt; 0))" name="leads_custom_fields_values_chained_list_catalog_id_check"/>
      </table>
      <table name="leads_custom_fields_values_checkbox" remarks="Таблица значений кастомных полей с типом чекбокс" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_checkbox_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_checkbox_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="leads_custom_fields_values_checkbox_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_leads_custom_fields_values_checkbox_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="leads_custom_fields_values_date" remarks="Таблица значений кастомных полей для типов связанных с датой" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_date_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_date_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="2" name="value" nullable="false" remarks="Значение в формате ГГГГ-ММ-ДД ЧЧ:мм:СС" size="29" type="timestamp" typeCode="93"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="leads_custom_fields_values_date_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_leads_custom_fields_values_date_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="leads_custom_fields_values_file" remarks="Таблица значений кастомных полей для файлов" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_file_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_file_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="file_name" nullable="false" remarks="Имя файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="file_size" nullable="false" remarks="Размер файла" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="file_uuid" nullable="false" remarks="UUID файла" size="2147483647" type="uuid" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="is_deleted" nullable="false" remarks="Удален ли файл" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="version_uuid" nullable="true" remarks="Версия UUID" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="leads_custom_fields_values_file_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_leads_custom_fields_values_file_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="leads_custom_fields_values_legal_entity" remarks="Таблица значений кастомных полей с типом Юр. лицо" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_legal_entity_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_legal_entity_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="name" nullable="true" remarks="Название организации" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="entity_type" nullable="true" remarks="Тип юридического лица. 1 – Частное, 2 – Юридическое." size="5" type="int2" typeCode="5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="address" nullable="true" remarks="Адрес" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="real_address" nullable="true" remarks="Факт. адрес" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="bank_account_number" nullable="true" remarks="Рассчетный счет" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="director" nullable="true" remarks="ФИО директора организации" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="vat_id" nullable="true" remarks="ИНН организации (Россия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="tax_registration_reason_code" nullable="true" remarks="ОГРНИП (Россия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="kpp" nullable="true" remarks="КПП организации (Россия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="bank_code" nullable="true" remarks="БИК" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="bin" nullable="true" remarks="БИН организации (Казахстан)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="unp" nullable="true" remarks="УНП организации (Белоруссия)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="egrpou" nullable="true" remarks="ЕГРПОУ организации (Украина)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="mfo" nullable="true" remarks="МФО организации (Украина/Узбекистан)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="oked" nullable="true" remarks="ОКЭД организации (Узбекистан)" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="external_uid" nullable="true" remarks="Идентификатор внешней системы" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="leads_custom_fields_values_legal_entity_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_leads_custom_fields_values_legal_entity_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <checkConstraint constraint="((entity_type &gt; 0))" name="leads_custom_fields_values_legal_entity_entity_type_check"/>
      </table>
      <table name="leads_custom_fields_values_numeric" remarks="Таблица значений кастомных полей с числовыми типами" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_numeric_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_numeric_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="is_computed" nullable="true" remarks="Расчитано ли значение по формуле" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="leads_custom_fields_values_numeric_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_leads_custom_fields_values_numeric_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="leads_custom_fields_values_select" remarks="Таблица значений кастомных полей с типами Список, Мультисписок, Переключатель (radiobutton)" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_select_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_select_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="enum_id" nullable="false" remarks="id выбранного варианта" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_select_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_enums"/>
         </column>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <primaryKey column="enum_id" sequenceNumberInPK="3"/>
         <index name="leads_custom_fields_values_select_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
            <column ascending="true" name="enum_id"/>
         </index>
         <index name="index_leads_custom_fields_values_select_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_leads_custom_fields_values_select_enum_id" unique="false">
            <column ascending="true" name="enum_id"/>
         </index>
      </table>
      <table name="leads_custom_fields_values_smart_address" remarks="Таблица значений кастомных полей с типом Адрес" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_smart_address_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_smart_address_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="enum_id" nullable="false" remarks="id типа поля (1 - Адрес, 2 - Адрес продолжение, 3 - Город, 4 - Регион, 5 - Индекс, 6 - Страна)" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_smart_address_enum_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields_enums"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="value" nullable="false" remarks="Значение" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <primaryKey column="enum_id" sequenceNumberInPK="3"/>
         <index name="leads_custom_fields_values_smart_address_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
            <column ascending="true" name="enum_id"/>
         </index>
         <index name="index_leads_custom_fields_values_smart_address_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_leads_custom_fields_values_smart_address_enum_id" unique="false">
            <column ascending="true" name="enum_id"/>
         </index>
      </table>
      <table name="leads_custom_fields_values_text" remarks="Таблица значений кастомных полей с текстовыми типами" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_text_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="custom_field_id" nullable="false" remarks="id кастомного поля" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_custom_fields_values_text_custom_field_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="custom_fields"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="value" nullable="false" remarks="Значение" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="custom_field_id" sequenceNumberInPK="2"/>
         <index name="leads_custom_fields_values_text_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="custom_field_id"/>
         </index>
         <index name="index_leads_custom_fields_values_text_custom_field_id" unique="false">
            <column ascending="true" name="custom_field_id"/>
         </index>
      </table>
      <table name="leads_notes" remarks="Таблица примечаний сделок" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <child column="note_id" foreignKey="leads_notes_amomail_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_amomail_message"/>
            <child column="note_id" foreignKey="leads_notes_attachment_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_attachment"/>
            <child column="note_id" foreignKey="leads_notes_call_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_call_in"/>
            <child column="note_id" foreignKey="leads_notes_call_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_call_out"/>
            <child column="note_id" foreignKey="leads_notes_common_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_common"/>
            <child column="note_id" foreignKey="leads_notes_extended_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_extended_service_message"/>
            <child column="note_id" foreignKey="leads_notes_geolocation_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_geolocation"/>
            <child column="note_id" foreignKey="leads_notes_link_followed_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_link_followed"/>
            <child column="note_id" foreignKey="leads_notes_message_cashier_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_message_cashier"/>
            <child column="note_id" foreignKey="leads_notes_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_service_message"/>
            <child column="note_id" foreignKey="leads_notes_sms_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_sms_in"/>
            <child column="note_id" foreignKey="leads_notes_sms_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes_sms_out"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="entity_id" nullable="false" remarks="id привязанной сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="false" remarks="id ответственного за примечание" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="note_type" nullable="false" remarks="id типа примечания" size="5" type="int2" typeCode="5">
            <parent column="id" foreignKey="leads_notes_note_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="notes_types"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="created_at" nullable="true" remarks="Дата создания примечания" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="updated_at" nullable="false" remarks="Дата изменения примечания" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="created_by" nullable="true" remarks="id пользователя, который создал примечание" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="updated_by" nullable="false" remarks="id пользователя, который изменил примечание" size="10" type="int4" typeCode="4"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="leads_notes_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="leads_notes_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="leads_notes_id_check"/>
         <checkConstraint constraint="((responsible_user_id &gt;= 0))" name="leads_notes_responsible_user_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="leads_notes_updated_by_check"/>
      </table>
      <table name="leads_notes_amomail_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Сообщение почты Амо&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_amomail_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="access_granted" nullable="true" remarks="Доступ предоставлен" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="attach_cnt" nullable="true" remarks="Количество вложений" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="content_summary" nullable="true" remarks="Текст письма" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="delivery_status" nullable="true" remarks="Статус доставки письма" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="delivery_time" nullable="true" remarks="Дата доставки письма" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="delivery_reason" nullable="true" remarks="Причины" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="from_email" nullable="false" remarks="Почта отправителя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="from_name" nullable="true" remarks="Имя отправителя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="to_email" nullable="false" remarks="Почта получателя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="to_name" nullable="true" remarks="Имя получателя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="income" nullable="false" remarks="Входящее ли письмо" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="message_id" nullable="false" remarks="id сообщения" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="owner_id" nullable="true" remarks="id владельца (скорее всего владельца почтового ящика)" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="private" nullable="true" remarks="Приватный ли почтовый ящик Амо" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="subject" nullable="true" remarks="Тема сообщения" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="thread_id" nullable="false" remarks="id треда" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="version" nullable="false" remarks="Версия" size="10" type="int4" typeCode="4"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_amomail_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_attachment" remarks="Таблица с содержимым (params) примечаний с типом &quot;Примечание с файлом&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_attachment_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="file_name" nullable="true" remarks="Имя файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="file_uuid" nullable="true" remarks="UUID файла" size="2147483647" type="uuid" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="is_drive_attachment" nullable="false" remarks="Загружен ли файл" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="original_name" nullable="false" remarks="Исходное название файла" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="version_uuid" nullable="true" remarks="Версия UUID" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_attachment_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_call_in" remarks="Таблица с содержимым (params) примечаний с типом &quot;Входящий звонок&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_call_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="call_result" nullable="true" remarks="Результат звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="call_status" nullable="true" remarks="Статус звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="uniq" nullable="true" remarks="Уникальный код разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="duration" nullable="true" remarks="Длительность разговора в секундах" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="source" nullable="true" remarks="Источник звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="link" nullable="true" remarks="Ссылка на запись разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="phone" nullable="true" remarks="Телефон" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_call_in_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_call_out" remarks="Таблица с содержимым (params) примечаний с типом &quot;Исходящий звонок&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_call_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="call_result" nullable="true" remarks="Результат звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="call_status" nullable="true" remarks="Статус звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="uniq" nullable="false" remarks="Уникальный код разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="duration" nullable="true" remarks="Длительность разговора в секундах" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="source" nullable="true" remarks="Источник звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="link" nullable="true" remarks="Ссылка на запись разговора" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="phone" nullable="true" remarks="Телефон" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_call_out_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_common" remarks="Таблица с содержимым (params) Текстовых примечаний" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_common_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_common_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_extended_service_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Расширенное системное сообщение&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_extended_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="service" nullable="true" remarks="Название сервиса" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_extended_service_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_geolocation" remarks="Таблица с содержимым (params) примечаний с типом &quot;Текстовое примечание с гео-координатами&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_geolocation_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="address" nullable="false" remarks="Адрес" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="3" name="longitude" nullable="false" remarks="Долгота" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="4" name="latitude" nullable="false" remarks="Широта" size="17" type="float8" typeCode="8"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_geolocation_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_link_followed" remarks="Таблица с содержимым (params) примечаний с типом &quot;Переход по ссылке&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_link_followed_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="url" nullable="false" remarks="URL адрес ссылки" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_link_followed_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_message_cashier" remarks="Таблица с содержимым (params) примечаний с типом &quot;Сообщение кассиру&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_message_cashier_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="status" nullable="false" remarks="Статус" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_message_cashier_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_service_message" remarks="Таблица с содержимым (params) примечаний с типом &quot;Системное сообщение&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_service_message_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="false" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="service" nullable="true" remarks="Название сервиса" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_service_message_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_sms_in" remarks="Таблица с содержимым (params) примечаний с типом &quot;Входящее SMS&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_sms_in_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="phone" nullable="true" remarks="Номер телефона" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_sms_in_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_sms_out" remarks="Таблица с содержимым (params) примечаний с типом &quot;Исхдящее SMS&quot;" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="note_id" nullable="false" remarks="id примечания" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_notes_sms_out_note_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="text" nullable="true" remarks="Текст примечания" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="phone" nullable="true" remarks="Номер телефона" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="note_id" sequenceNumberInPK="1"/>
         <index name="leads_notes_sms_out_pkey" unique="true">
            <column ascending="true" name="note_id"/>
         </index>
      </table>
      <table name="leads_notes_unknown" remarks="" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="entity_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="note_type" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="created_at" nullable="true" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="updated_at" nullable="false" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="created_by" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="updated_by" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="params" nullable="false" remarks="" size="2147483647" type="json" typeCode="1111"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="leads_notes_unknown_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="leads_notes_unknown_created_by_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="leads_notes_unknown_id_check"/>
         <checkConstraint constraint="((responsible_user_id &gt;= 0))" name="leads_notes_unknown_responsible_user_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="leads_notes_unknown_updated_by_check"/>
      </table>
      <table name="leads_tags" numRows="1027" remarks="Таблица с тегами сделок" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id тега" size="10" type="int4" typeCode="4">
            <child column="tag_id" foreignKey="leads_to_tags_tag_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_to_tags"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название тега" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="color" nullable="true" remarks="Цвет тега" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="3" name="is_deleted" nullable="false" remarks="Удален ли тег" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="leads_tags_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="index_leads_tags_name" unique="false">
            <column ascending="true" name="name"/>
         </index>
         <checkConstraint constraint="((id &gt; 0))" name="leads_tags_id_check"/>
      </table>
      <table name="leads_to_tags" remarks="Таблица с привязкой тегов к сделкам" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="entity_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_to_tags_entity_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="tag_id" nullable="false" remarks="id тега" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="leads_to_tags_tag_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_tags"/>
         </column>
         <primaryKey column="entity_id" sequenceNumberInPK="1"/>
         <primaryKey column="tag_id" sequenceNumberInPK="2"/>
         <index name="leads_to_tags_pkey" unique="true">
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="tag_id"/>
         </index>
         <index name="index_leads_to_tags_tag_id" unique="false">
            <column ascending="true" name="tag_id"/>
         </index>
      </table>
      <table name="loss_reasons" remarks="Таблица причин отказов" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id причины отказа" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название причины отказа" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="2" name="created_at" nullable="false" remarks="Дата создания причины отказа" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="3" name="updated_at" nullable="false" remarks="Дата обновления причины отказа" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="4" name="is_deleted" nullable="false" remarks="Удалена ли причина отказа" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="loss_reasons_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="notes_types" remarks="Таблица типов примечаний" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id типа" size="5" type="int2" typeCode="5">
            <child column="note_type" foreignKey="companies_notes_note_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies_notes"/>
            <child column="note_type" foreignKey="contacts_notes_note_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts_notes"/>
            <child column="note_type" foreignKey="customers_notes_note_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers_notes"/>
            <child column="note_type" foreignKey="leads_notes_note_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads_notes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="type" nullable="false" remarks="название типа" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="notes_types_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="pipelines" numRows="52" remarks="Таблица воронок продаж" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id воронки" size="10" type="int4" typeCode="4">
            <child column="pipeline_id" foreignKey="leads_pipeline_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
            <child column="pipeline_id" foreignKey="statuses_pipeline_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="statuses"/>
            <child column="pipeline_id" foreignKey="unsorted_pipeline_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название воронки" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="is_archive" nullable="false" remarks="Является ли воронка архивной" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="sort" nullable="false" remarks="Сортировка воронки" size="5" type="int2" typeCode="5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="is_unsorted_on" nullable="false" remarks="Включено ли неразобранное в воронке" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="is_main" nullable="false" remarks="Является ли воронка главной" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="6" name="is_deleted" nullable="false" remarks="Удалена ли воронка" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="pipelines_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="roles" remarks="Таблица ролей пользователей" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id роли" size="10" type="int4" typeCode="4">
            <child column="role_id" foreignKey="users_role_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название роли" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="2" name="is_deleted" nullable="false" remarks="Удалена ли роль" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="roles_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="statuses" numRows="538" remarks="Таблица статусов (этапов)" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id статуса" size="10" type="int4" typeCode="4">
            <child column="status_id" foreignKey="leads_status_id_pipeline_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название статуса" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="pipeline_id" nullable="false" remarks="id воронки, в которой находится статус" size="10" type="int4" typeCode="4">
            <child column="pipeline_id" foreignKey="leads_status_id_pipeline_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
            <parent column="id" foreignKey="statuses_pipeline_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="pipelines"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="sort" nullable="false" remarks="Сортировка статуса" size="5" type="int2" typeCode="5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="type" nullable="false" remarks="Тип статуса (1 – неразобранное, 0 – обычный статус)" size="5" type="int2" typeCode="5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="is_editable" nullable="false" remarks="Доступен ли статус для редактирования" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="color" nullable="false" remarks="Цвет статуса" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="7" name="is_deleted" nullable="false" remarks="Удален ли статус" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <primaryKey column="pipeline_id" sequenceNumberInPK="2"/>
         <index name="statuses_pkey" unique="true">
            <column ascending="true" name="id"/>
            <column ascending="true" name="pipeline_id"/>
         </index>
      </table>
      <table name="task_types" numRows="115" remarks="Таблица типов задач" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id типа" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="Название типа" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="2" name="is_deleted" nullable="false" remarks="Удален ли статус" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="task_types_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="tasks" remarks="Таблица задач" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id задачи" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="created_by" nullable="false" remarks="id пользователя, который создал задачу" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="updated_by" nullable="true" remarks="id пользователя, который изменил задачу" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="3" name="created_at" nullable="false" remarks="Дата создания задачи" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="updated_at" nullable="false" remarks="Дата изменения задачи" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="responsible_user_id" nullable="false" remarks="id пользователя, ответственного за задачу" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="entity_id" nullable="true" remarks="id сущности, к которой привязана задача" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="entity_type_id" nullable="true" remarks="id типа сущности, к которой привязана задача" size="5" type="int2" typeCode="5">
            <parent column="id" foreignKey="tasks_entity_type_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="tasks_entity_types"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="is_completed" nullable="false" remarks="Выполнена ли задача" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="is_deleted" nullable="false" remarks="Удалена ли задача" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="text" nullable="false" remarks="Описание задачи" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="task_type_id" nullable="false" remarks="id типа задачи" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="duration" nullable="true" remarks="Длительность задачи в секундах" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="complete_till" nullable="true" remarks="Дата, когда задача должна быть завершена" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="result_text" nullable="true" remarks="Текст результата выполнения задачи" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="tasks_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="tasks_entity_type_id_entity_id_is_completed_idx" unique="false">
            <column ascending="true" name="entity_type_id"/>
            <column ascending="true" name="entity_id"/>
            <column ascending="true" name="is_completed"/>
         </index>
         <checkConstraint constraint="((created_by &gt;= 0))" name="tasks_created_by_check"/>
         <checkConstraint constraint="((duration &gt;= 0))" name="tasks_duration_check"/>
         <checkConstraint constraint="((id &gt; 0))" name="tasks_id_check"/>
         <checkConstraint constraint="((updated_by &gt;= 0))" name="tasks_updated_by_check"/>
      </table>
      <table name="tasks_entity_types" remarks="Таблица типов сущностей" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id типа" size="5" type="int2" typeCode="5">
            <child column="entity_type_id" foreignKey="tasks_entity_type_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="tasks"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="type" nullable="false" remarks="Название типа" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="tasks_entity_types_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="tasks_entity_types_type_key" unique="true">
            <column ascending="true" name="type"/>
         </index>
         <checkConstraint constraint="((id &gt; 0))" name="tasks_entity_types_id_check"/>
      </table>
      <table name="unknown_events" remarks="" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="event_id" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="1" name="created_at" nullable="false" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="created_by" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="entity_id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="entity_type" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="unknown_events_entity_type_fkey" implied="false" onDeleteCascade="false" schema="public" table="events_entity_types"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="event_type" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="value_before" nullable="false" remarks="" size="2147483647" type="json" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="value_after" nullable="false" remarks="" size="2147483647" type="json" typeCode="1111"/>
         <primaryKey column="event_id" sequenceNumberInPK="1"/>
         <index name="unknown_events_pkey" unique="true">
            <column ascending="true" name="event_id"/>
         </index>
      </table>
      <table name="unsorted" remarks="Таблица неразобранного" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="uid" nullable="false" remarks="uid неразобранного" size="2147483647" type="text" typeCode="12">
            <child column="uid" foreignKey="unsorted_metadata_chats_uid_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted_metadata_chats"/>
            <child column="uid" foreignKey="unsorted_metadata_forms_uid_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted_metadata_forms"/>
            <child column="uid" foreignKey="unsorted_metadata_mail_uid_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted_metadata_mail"/>
            <child column="uid" foreignKey="unsorted_metadata_sip_uid_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted_metadata_sip"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="source_uid" nullable="true" remarks="uid источника заявки" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="source_name" nullable="true" remarks="Название источника заявки" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="category_id" nullable="false" remarks="id категории неразобранного" size="5" type="int2" typeCode="5">
            <parent column="id" foreignKey="unsorted_category_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted_categories"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="pipeline_id" nullable="true" remarks="id воронки, в которой находится неразобранное" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="unsorted_pipeline_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="pipelines"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="created_at" nullable="false" remarks="Дата создания неразобранного" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="lead_id" nullable="false" remarks="id сделки" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="unsorted_lead_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="contact_id" nullable="true" remarks="id контакта" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="company_id" nullable="true" remarks="id компании" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="9" name="is_deleted" nullable="false" remarks="Удалено ли неразобранное" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="uid" sequenceNumberInPK="1"/>
         <index name="unsorted_pkey" unique="true">
            <column ascending="true" name="uid"/>
         </index>
      </table>
      <table name="unsorted_categories" remarks="Таблица категорий неразобранного" schema="public" type="TABLE">
         <column autoUpdated="true" defaultValue="nextval('unsorted_categories_id_seq'::regclass)" digits="0" id="0" name="id" nullable="false" remarks="id категории" size="5" type="smallserial" typeCode="5">
            <child column="category_id" foreignKey="unsorted_category_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="category" nullable="false" remarks="Категория неразобранного (sip, forms, chats, mail)" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="unsorted_categories_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="unsorted_categories_category_key" unique="true">
            <column ascending="true" name="category"/>
         </index>
      </table>
      <table name="unsorted_metadata_chats" remarks="Таблица метадаты неразобранного с типом чат" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="uid" nullable="false" remarks="uid неразобранного, к которому относится metadata" size="2147483647" type="text" typeCode="12">
            <parent column="uid" foreignKey="unsorted_metadata_chats_uid_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="from" nullable="false" remarks="От кого чат" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="to" nullable="false" remarks="Кому чат" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="3" name="received_at" nullable="false" remarks="Дата получения письма в чате" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="service" nullable="false" remarks="Название сервиса" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="client_name" nullable="true" remarks="Имя клиента" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="client_avatar" nullable="true" remarks="Ссылка на картинку клиента" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="origin_chat_id" nullable="false" remarks="id чата" size="2147483647" type="uuid" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="origin_ref" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="origin_visitor_uid" nullable="true" remarks="" size="2147483647" type="uuid" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="last_message_text" nullable="true" remarks="Текст последнего сообщения" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="source_name" nullable="true" remarks="Имя источника неразобранного" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="uid" sequenceNumberInPK="1"/>
         <index name="unsorted_metadata_chats_pkey" unique="true">
            <column ascending="true" name="uid"/>
         </index>
      </table>
      <table name="unsorted_metadata_forms" remarks="Таблица метадаты неразобранного с типом форма" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="uid" nullable="false" remarks="uid неразобранного, к которому относится metadata" size="2147483647" type="text" typeCode="12">
            <parent column="uid" foreignKey="unsorted_metadata_forms_uid_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="form_id" nullable="false" remarks="id формы" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="form_name" nullable="false" remarks="Название формы" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="form_page" nullable="false" remarks="Текст на неразобранном" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="ip" nullable="true" remarks="ip отправителя формы" size="2147483647" type="cidr" typeCode="1111"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="form_sent_at" nullable="false" remarks="Дата отправки формы" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="referer" nullable="true" remarks="Хост" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="visitor_uid" nullable="true" remarks="" size="2147483647" type="uuid" typeCode="1111"/>
         <primaryKey column="uid" sequenceNumberInPK="1"/>
         <index name="unsorted_metadata_forms_pkey" unique="true">
            <column ascending="true" name="uid"/>
         </index>
      </table>
      <table name="unsorted_metadata_mail" remarks="Таблица метадаты неразобранного с типом форма" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="uid" nullable="false" remarks="uid неразобранного, к которому относится metadata" size="2147483647" type="text" typeCode="12">
            <parent column="uid" foreignKey="unsorted_metadata_mail_uid_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="from_email" nullable="false" remarks="email отправителя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="from_name" nullable="true" remarks="Имя отправителя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="3" name="received_at" nullable="false" remarks="Дата получения письма" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="subject" nullable="false" remarks="Тема письма" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="thread_id" nullable="false" remarks="id треда" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="message_id" nullable="false" remarks="id сообщения" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="content_summary" nullable="true" remarks="Краткое содержание письма" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="uid" sequenceNumberInPK="1"/>
         <index name="unsorted_metadata_mail_pkey" unique="true">
            <column ascending="true" name="uid"/>
         </index>
         <checkConstraint constraint="((message_id &gt; 0))" name="unsorted_metadata_mail_message_id_check"/>
         <checkConstraint constraint="((thread_id &gt; 0))" name="unsorted_metadata_mail_thread_id_check"/>
      </table>
      <table name="unsorted_metadata_sip" remarks="Таблица метадаты sip неразобранного" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="uid" nullable="false" remarks="uid неразобранного, к которому относится metadata" size="2147483647" type="text" typeCode="12">
            <parent column="uid" foreignKey="unsorted_metadata_sip_uid_fkey" implied="false" onDeleteCascade="false" schema="public" table="unsorted"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="phone" nullable="false" remarks="От кого сделан звонок" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="2" name="called_at" nullable="false" remarks="Время звонка" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="duration" nullable="false" remarks="Длительность звонка" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="link" nullable="true" remarks="Ссылка на запись звонка" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="service_code" nullable="false" remarks="Код сервиса, через который сделан звонок" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="from" nullable="true" remarks="Источник звонка" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="uid" sequenceNumberInPK="1"/>
         <index name="unsorted_metadata_sip_pkey" unique="true">
            <column ascending="true" name="uid"/>
         </index>
         <checkConstraint constraint="((duration &gt;= 0))" name="unsorted_metadata_sip_duration_check"/>
      </table>
      <table name="users" numRows="607" remarks="Таблица Пользователей" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="id пользователя" size="10" type="int4" typeCode="4">
            <child column="responsible_user_id" foreignKey="companies_responsible_user_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="companies"/>
            <child column="responsible_user_id" foreignKey="contacts_responsible_user_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="contacts"/>
            <child column="responsible_user_id" foreignKey="customers_responsible_user_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="customers"/>
            <child column="responsible_user_id" foreignKey="leads_responsible_user_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="leads"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="role_id" nullable="true" remarks="id роли пользователя" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="users_role_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="roles"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="group_id" nullable="true" remarks="id группы пользователя" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="name" nullable="false" remarks="Имя пользователя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="email" nullable="false" remarks="Email пользователя" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="is_active" nullable="false" remarks="Является ли пользователь активным" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="6" name="is_deleted" nullable="false" remarks="Удален ли пользователь" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="users_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="users_groups" remarks="" schema="public" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="false" digits="0" id="2" name="is_deleted" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="users_groups_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="view_contacts_notes_call" numRows="0" remarks="" schema="public" type="VIEW" viewSql=" SELECT n.id,&#10;    n.entity_id,&#10;    n.responsible_user_id,&#10;    n.note_type,&#10;    n.created_at,&#10;    n.updated_at,&#10;    n.created_by,&#10;    n.updated_by,&#10;    cl.note_id,&#10;    cl.call_result,&#10;    cl.call_status,&#10;    cl.uniq,&#10;    cl.duration,&#10;    cl.source,&#10;    cl.link,&#10;    cl.phone&#10;   FROM (contacts_notes n&#10;     LEFT JOIN contacts_notes_call_out cl ON ((n.id = cl.note_id)))&#10;  WHERE (n.note_type = 11)&#10;UNION&#10; SELECT n.id,&#10;    n.entity_id,&#10;    n.responsible_user_id,&#10;    n.note_type,&#10;    n.created_at,&#10;    n.updated_at,&#10;    n.created_by,&#10;    n.updated_by,&#10;    cl.note_id,&#10;    cl.call_result,&#10;    cl.call_status,&#10;    cl.uniq,&#10;    cl.duration,&#10;    cl.source,&#10;    cl.link,&#10;    cl.phone&#10;   FROM (contacts_notes n&#10;     LEFT JOIN contacts_notes_call_in cl ON ((n.id = cl.note_id)))&#10;  WHERE (n.note_type = 10);">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="entity_id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="responsible_user_id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="note_type" nullable="true" remarks="" size="5" type="int2" typeCode="5"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="created_at" nullable="true" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="5" name="updated_at" nullable="true" remarks="" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="created_by" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="updated_by" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="note_id" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="call_result" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="call_status" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="uniq" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="12" name="duration" nullable="true" remarks="" size="17" type="float8" typeCode="8"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="source" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="link" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="phone" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
      </table>
      <table name="view_leads_custom_fields_values" numRows="0" remarks="представление сделок с кастомными полями" schema="public" type="VIEW" viewSql=" SELECT leads.id,&#10;    leads.name,&#10;    leads.price,&#10;    leads.responsible_user_id,&#10;    leads.status_id,&#10;    leads.pipeline_id,&#10;    leads.loss_reason_id,&#10;    leads.source_id,&#10;    leads.created_by,&#10;    leads.updated_by,&#10;    leads.closed_at,&#10;    leads.created_at,&#10;    leads.updated_at,&#10;    leads.closest_task_at,&#10;    leads.is_deleted,&#10;    leads.score,&#10;    leads.labor_cost,&#10;    leads.is_price_modified_by_robot,&#10;    leads.is_price_computed,&#10;    cf.id AS custom_field_id,&#10;    cf.name AS custom_field_name,&#10;    COALESCE(test_select1.value, test_select4.value) AS custom_field_value_text,&#10;    test_select2.value AS custom_field_value_number,&#10;    test_select3.value AS custom_field_value_bool,&#10;    test_select5.value AS custom_field_value_date,&#10;    cf.is_deleted AS custom_field_is_deleted,&#10;    cf.code AS custom_field_code&#10;   FROM ((((((leads&#10;     JOIN custom_fields cf ON ((0 = 0)))&#10;     LEFT JOIN ( SELECT lcf.entity_id,&#10;            lcf.custom_field_id,&#10;            lcf.enum_id,&#10;            cfe.id,&#10;            cfe.code,&#10;            cfe.value,&#10;            cfe.is_deleted&#10;           FROM (leads_custom_fields_values_select lcf&#10;             JOIN custom_fields_enums cfe ON ((lcf.enum_id = cfe.id)))) test_select1 ON (((test_select1.entity_id = leads.id) AND (test_select1.custom_field_id = cf.id))))&#10;     LEFT JOIN leads_custom_fields_values_numeric test_select2 ON (((test_select2.entity_id = leads.id) AND (test_select2.custom_field_id = cf.id))))&#10;     LEFT JOIN leads_custom_fields_values_checkbox test_select3 ON (((test_select3.entity_id = leads.id) AND (test_select3.custom_field_id = cf.id))))&#10;     LEFT JOIN leads_custom_fields_values_text test_select4 ON (((test_select4.entity_id = leads.id) AND (test_select4.custom_field_id = cf.id))))&#10;     LEFT JOIN leads_custom_fields_values_date test_select5 ON (((test_select5.entity_id = leads.id) AND (test_select5.custom_field_id = cf.id))))&#10;  ORDER BY leads.id;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="id сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="true" remarks="Название сделки" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="price" nullable="true" remarks="Бюджет сделки" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="responsible_user_id" nullable="true" remarks="id пользователя, ответственного за сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="status_id" nullable="true" remarks="id статуса" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="pipeline_id" nullable="true" remarks="id воронки продаж" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="loss_reason_id" nullable="true" remarks="id причины отказа" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="source_id" nullable="true" remarks="id источника сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="created_by" nullable="true" remarks="id пользователя, который создал сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="updated_by" nullable="true" remarks="id пользователя, который изменил сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="10" name="closed_at" nullable="true" remarks="Дата закрытия сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="11" name="created_at" nullable="true" remarks="Дата создания сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="12" name="updated_at" nullable="true" remarks="Дата изменения сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="closest_task_at" nullable="true" remarks="Дата ближайшей задачи к выполнению" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="is_deleted" nullable="true" remarks="Удалена ли сделка" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="score" nullable="true" remarks="Скоринг сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="labor_cost" nullable="true" remarks="Тип поля &quot;стоимость труда&quot; показывает сколько времени было затрачено на работу со сделкой. Время исчисления в секундах" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="is_price_modified_by_robot" nullable="true" remarks="Изменен ли в последний раз бюджет сделки роботом" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="18" name="is_price_computed" nullable="true" remarks="Был ли бюджет вычеслен по формуле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="19" name="custom_field_id" nullable="true" remarks="id кастомного поля" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="20" name="custom_field_name" nullable="true" remarks="название кастомного поля" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="21" name="custom_field_value_text" nullable="true" remarks="значение кастомного поля типа текст" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="22" name="custom_field_value_number" nullable="true" remarks="значение кастомного поля типа число" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="23" name="custom_field_value_bool" nullable="true" remarks="значение кастомного поля типа чекбокс" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="24" name="custom_field_value_date" nullable="true" remarks="значение кастомного поля связанного с датой" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="25" name="custom_field_is_deleted" nullable="true" remarks="удалено ли кастомное поле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="26" name="custom_field_code" nullable="true" remarks="Код кастомного поля" size="2147483647" type="text" typeCode="12"/>
      </table>
      <table name="view_leads_custom_fields_values_checkbox" numRows="0" remarks="представление сделок с кастомными полями типа чекбокс" schema="public" type="VIEW" viewSql=" SELECT leads.id,&#10;    leads.name,&#10;    leads.price,&#10;    leads.responsible_user_id,&#10;    leads.status_id,&#10;    leads.pipeline_id,&#10;    leads.loss_reason_id,&#10;    leads.source_id,&#10;    leads.created_by,&#10;    leads.updated_by,&#10;    leads.closed_at,&#10;    leads.created_at,&#10;    leads.updated_at,&#10;    leads.closest_task_at,&#10;    leads.is_deleted,&#10;    leads.score,&#10;    leads.labor_cost,&#10;    leads.is_price_modified_by_robot,&#10;    leads.is_price_computed,&#10;    cf.id AS custom_field_id,&#10;    cf.name AS custom_field_name,&#10;    lcf.value AS custom_field_value_bool,&#10;    cf.is_deleted AS custom_field_is_deleted,&#10;    cf.code AS custom_field_code&#10;   FROM ((leads&#10;     JOIN custom_fields cf ON ((cf.type_id = 3)))&#10;     LEFT JOIN leads_custom_fields_values_checkbox lcf ON (((lcf.entity_id = leads.id) AND (lcf.custom_field_id = cf.id))))&#10;  ORDER BY leads.id;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="id сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="true" remarks="Название сделки" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="price" nullable="true" remarks="Бюджет сделки" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="responsible_user_id" nullable="true" remarks="id пользователя, ответственного за сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="status_id" nullable="true" remarks="id статуса" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="pipeline_id" nullable="true" remarks="id воронки продаж" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="loss_reason_id" nullable="true" remarks="id причины отказа" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="source_id" nullable="true" remarks="id источника сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="created_by" nullable="true" remarks="id пользователя, который создал сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="updated_by" nullable="true" remarks="id пользователя, который изменил сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="10" name="closed_at" nullable="true" remarks="Дата закрытия сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="11" name="created_at" nullable="true" remarks="Дата создания сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="12" name="updated_at" nullable="true" remarks="Дата изменения сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="closest_task_at" nullable="true" remarks="Дата ближайшей задачи к выполнению" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="is_deleted" nullable="true" remarks="Удалена ли сделка" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="score" nullable="true" remarks="Скоринг сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="labor_cost" nullable="true" remarks="Тип поля &quot;стоимость труда&quot; показывает сколько времени было затрачено на работу со сделкой. Время исчисления в секундах" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="is_price_modified_by_robot" nullable="true" remarks="Изменен ли в последний раз бюджет сделки роботом" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="18" name="is_price_computed" nullable="true" remarks="Был ли бюджет вычеслен по формуле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="19" name="custom_field_id" nullable="true" remarks="id кастомного поля" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="20" name="custom_field_name" nullable="true" remarks="название кастомного поля" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="21" name="custom_field_value_bool" nullable="true" remarks="значение кастомного поля типа чекбокс" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="22" name="custom_field_is_deleted" nullable="true" remarks="удалено ли кастомное поле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="23" name="custom_field_code" nullable="true" remarks="Код кастомного поля" size="2147483647" type="text" typeCode="12"/>
      </table>
      <table name="view_leads_custom_fields_values_date" numRows="0" remarks="представление сделок с кастомными полями связанных с датой" schema="public" type="VIEW" viewSql=" SELECT leads.id,&#10;    leads.name,&#10;    leads.price,&#10;    leads.responsible_user_id,&#10;    leads.status_id,&#10;    leads.pipeline_id,&#10;    leads.loss_reason_id,&#10;    leads.source_id,&#10;    leads.created_by,&#10;    leads.updated_by,&#10;    leads.closed_at,&#10;    leads.created_at,&#10;    leads.updated_at,&#10;    leads.closest_task_at,&#10;    leads.is_deleted,&#10;    leads.score,&#10;    leads.labor_cost,&#10;    leads.is_price_modified_by_robot,&#10;    leads.is_price_computed,&#10;    cf.id AS custom_field_id,&#10;    cf.name AS custom_field_name,&#10;    lcf.value AS custom_field_value_date,&#10;    cf.is_deleted AS custom_field_is_deleted,&#10;    cf.code AS custom_field_code&#10;   FROM ((leads&#10;     JOIN custom_fields cf ON ((cf.type_id = ANY (ARRAY[6, 14, 19]))))&#10;     LEFT JOIN leads_custom_fields_values_date lcf ON (((lcf.entity_id = leads.id) AND (lcf.custom_field_id = cf.id))))&#10;  ORDER BY leads.id;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="id сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="true" remarks="Название сделки" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="price" nullable="true" remarks="Бюджет сделки" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="responsible_user_id" nullable="true" remarks="id пользователя, ответственного за сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="status_id" nullable="true" remarks="id статуса" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="pipeline_id" nullable="true" remarks="id воронки продаж" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="loss_reason_id" nullable="true" remarks="id причины отказа" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="source_id" nullable="true" remarks="id источника сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="created_by" nullable="true" remarks="id пользователя, который создал сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="updated_by" nullable="true" remarks="id пользователя, который изменил сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="10" name="closed_at" nullable="true" remarks="Дата закрытия сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="11" name="created_at" nullable="true" remarks="Дата создания сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="12" name="updated_at" nullable="true" remarks="Дата изменения сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="closest_task_at" nullable="true" remarks="Дата ближайшей задачи к выполнению" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="is_deleted" nullable="true" remarks="Удалена ли сделка" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="score" nullable="true" remarks="Скоринг сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="labor_cost" nullable="true" remarks="Тип поля &quot;стоимость труда&quot; показывает сколько времени было затрачено на работу со сделкой. Время исчисления в секундах" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="is_price_modified_by_robot" nullable="true" remarks="Изменен ли в последний раз бюджет сделки роботом" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="18" name="is_price_computed" nullable="true" remarks="Был ли бюджет вычеслен по формуле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="19" name="custom_field_id" nullable="true" remarks="id кастомного поля" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="20" name="custom_field_name" nullable="true" remarks="название кастомного поля" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="21" name="custom_field_value_date" nullable="true" remarks="значение кастомного поля связанного с датой" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="22" name="custom_field_is_deleted" nullable="true" remarks="удалено ли кастомное поле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="23" name="custom_field_code" nullable="true" remarks="Код кастомного поля" size="2147483647" type="text" typeCode="12"/>
      </table>
      <table name="view_leads_custom_fields_values_numeric" numRows="0" remarks="представление сделок с их кастомными полями типа число" schema="public" type="VIEW" viewSql=" SELECT leads.id,&#10;    leads.name,&#10;    leads.price,&#10;    leads.responsible_user_id,&#10;    leads.status_id,&#10;    leads.pipeline_id,&#10;    leads.loss_reason_id,&#10;    leads.source_id,&#10;    leads.created_by,&#10;    leads.updated_by,&#10;    leads.closed_at,&#10;    leads.created_at,&#10;    leads.updated_at,&#10;    leads.closest_task_at,&#10;    leads.is_deleted,&#10;    leads.score,&#10;    leads.labor_cost,&#10;    leads.is_price_modified_by_robot,&#10;    leads.is_price_computed,&#10;    cf.id AS custom_field_id,&#10;    cf.name AS custom_field_name,&#10;    lcf.value AS custom_field_value_numeric,&#10;    lcf.is_computed AS custom_field_is_computed,&#10;    cf.is_deleted AS custom_field_is_deleted,&#10;    cf.code AS custom_field_code&#10;   FROM ((leads&#10;     JOIN custom_fields cf ON ((cf.type_id = ANY (ARRAY[2, 20, 23]))))&#10;     LEFT JOIN leads_custom_fields_values_numeric lcf ON (((lcf.entity_id = leads.id) AND (lcf.custom_field_id = cf.id))))&#10;  ORDER BY leads.id;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="id сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="true" remarks="Название сделки" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="price" nullable="true" remarks="Бюджет сделки" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="responsible_user_id" nullable="true" remarks="id пользователя, ответственного за сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="status_id" nullable="true" remarks="id статуса" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="pipeline_id" nullable="true" remarks="id воронки продаж" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="loss_reason_id" nullable="true" remarks="id причины отказа" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="source_id" nullable="true" remarks="id источника сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="created_by" nullable="true" remarks="id пользователя, который создал сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="updated_by" nullable="true" remarks="id пользователя, который изменил сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="10" name="closed_at" nullable="true" remarks="Дата закрытия сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="11" name="created_at" nullable="true" remarks="Дата создания сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="12" name="updated_at" nullable="true" remarks="Дата изменения сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="closest_task_at" nullable="true" remarks="Дата ближайшей задачи к выполнению" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="is_deleted" nullable="true" remarks="Удалена ли сделка" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="score" nullable="true" remarks="Скоринг сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="labor_cost" nullable="true" remarks="Тип поля &quot;стоимость труда&quot; показывает сколько времени было затрачено на работу со сделкой. Время исчисления в секундах" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="is_price_modified_by_robot" nullable="true" remarks="Изменен ли в последний раз бюджет сделки роботом" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="18" name="is_price_computed" nullable="true" remarks="Был ли бюджет вычеслен по формуле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="19" name="custom_field_id" nullable="true" remarks="id кастомного поля" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="20" name="custom_field_name" nullable="true" remarks="название кастомного поля" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="21" name="custom_field_value_numeric" nullable="true" remarks="значение кастомного поля типа число" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="22" name="custom_field_is_computed" nullable="true" remarks="расчитано ли значение по формуле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="23" name="custom_field_is_deleted" nullable="true" remarks="удалено ли кастомное поле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="24" name="custom_field_code" nullable="true" remarks="Код кастомного поля" size="2147483647" type="text" typeCode="12"/>
      </table>
      <table name="view_leads_custom_fields_values_select" numRows="0" remarks="представление сделок с их кастомными полями типа список-мультисписок" schema="public" type="VIEW" viewSql=" SELECT leads.id,&#10;    leads.name,&#10;    leads.price,&#10;    leads.responsible_user_id,&#10;    leads.status_id,&#10;    leads.pipeline_id,&#10;    leads.loss_reason_id,&#10;    leads.source_id,&#10;    leads.created_by,&#10;    leads.updated_by,&#10;    leads.closed_at,&#10;    leads.created_at,&#10;    leads.updated_at,&#10;    leads.closest_task_at,&#10;    leads.is_deleted,&#10;    leads.score,&#10;    leads.labor_cost,&#10;    leads.is_price_modified_by_robot,&#10;    leads.is_price_computed,&#10;    cf.id AS custom_field_id,&#10;    cf.name AS custom_field_name,&#10;    cfe.value AS custom_field_value_text,&#10;    lcf.enum_id AS custom_field_enum_id,&#10;    cf.is_deleted AS custom_field_is_deleted,&#10;    cf.code AS custom_field_code&#10;   FROM (((leads&#10;     JOIN custom_fields cf ON ((cf.type_id = ANY (ARRAY[4, 5, 10]))))&#10;     LEFT JOIN leads_custom_fields_values_select lcf ON (((lcf.entity_id = leads.id) AND (lcf.custom_field_id = cf.id))))&#10;     LEFT JOIN custom_fields_enums cfe ON ((lcf.enum_id = cfe.id)))&#10;  ORDER BY leads.id;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="id сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="true" remarks="Название сделки" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="price" nullable="true" remarks="Бюджет сделки" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="responsible_user_id" nullable="true" remarks="id пользователя, ответственного за сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="status_id" nullable="true" remarks="id статуса" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="pipeline_id" nullable="true" remarks="id воронки продаж" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="loss_reason_id" nullable="true" remarks="id причины отказа" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="source_id" nullable="true" remarks="id источника сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="created_by" nullable="true" remarks="id пользователя, который создал сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="updated_by" nullable="true" remarks="id пользователя, который изменил сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="10" name="closed_at" nullable="true" remarks="Дата закрытия сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="11" name="created_at" nullable="true" remarks="Дата создания сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="12" name="updated_at" nullable="true" remarks="Дата изменения сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="closest_task_at" nullable="true" remarks="Дата ближайшей задачи к выполнению" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="is_deleted" nullable="true" remarks="Удалена ли сделка" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="score" nullable="true" remarks="Скоринг сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="labor_cost" nullable="true" remarks="Тип поля &quot;стоимость труда&quot; показывает сколько времени было затрачено на работу со сделкой. Время исчисления в секундах" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="is_price_modified_by_robot" nullable="true" remarks="Изменен ли в последний раз бюджет сделки роботом" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="18" name="is_price_computed" nullable="true" remarks="Был ли бюджет вычеслен по формуле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="19" name="custom_field_id" nullable="true" remarks="id кастомного поля" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="20" name="custom_field_name" nullable="true" remarks="название кастомного поля" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="21" name="custom_field_value_text" nullable="true" remarks="значение кастомного поля типа текст" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="22" name="custom_field_enum_id" nullable="true" remarks="id выбранного варианта" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="23" name="custom_field_is_deleted" nullable="true" remarks="удалено ли кастомное поле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="24" name="custom_field_code" nullable="true" remarks="Код кастомного поля" size="2147483647" type="text" typeCode="12"/>
      </table>
      <table name="view_leads_custom_fields_values_text" numRows="0" remarks="представление сделок с кастомными полями типа текст" schema="public" type="VIEW" viewSql=" SELECT leads.id,&#10;    leads.name,&#10;    leads.price,&#10;    leads.responsible_user_id,&#10;    leads.status_id,&#10;    leads.pipeline_id,&#10;    leads.loss_reason_id,&#10;    leads.source_id,&#10;    leads.created_by,&#10;    leads.updated_by,&#10;    leads.closed_at,&#10;    leads.created_at,&#10;    leads.updated_at,&#10;    leads.closest_task_at,&#10;    leads.is_deleted,&#10;    leads.score,&#10;    leads.labor_cost,&#10;    leads.is_price_modified_by_robot,&#10;    leads.is_price_computed,&#10;    cf.id AS custom_field_id,&#10;    cf.name AS custom_field_name,&#10;    lcf.value AS custom_field_value_text,&#10;    cf.is_deleted AS custom_field_is_deleted,&#10;    cf.code AS custom_field_code&#10;   FROM ((leads&#10;     JOIN custom_fields cf ON ((cf.type_id = ANY (ARRAY[1, 7, 8, 9, 11, 21]))))&#10;     LEFT JOIN leads_custom_fields_values_text lcf ON (((lcf.entity_id = leads.id) AND (lcf.custom_field_id = cf.id))))&#10;  ORDER BY leads.id;">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="true" remarks="id сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="true" remarks="Название сделки" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="price" nullable="true" remarks="Бюджет сделки" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="responsible_user_id" nullable="true" remarks="id пользователя, ответственного за сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="status_id" nullable="true" remarks="id статуса" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="pipeline_id" nullable="true" remarks="id воронки продаж" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="loss_reason_id" nullable="true" remarks="id причины отказа" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="source_id" nullable="true" remarks="id источника сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="created_by" nullable="true" remarks="id пользователя, который создал сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="updated_by" nullable="true" remarks="id пользователя, который изменил сделку" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="10" name="closed_at" nullable="true" remarks="Дата закрытия сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="11" name="created_at" nullable="true" remarks="Дата создания сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="12" name="updated_at" nullable="true" remarks="Дата изменения сделки" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="13" name="closest_task_at" nullable="true" remarks="Дата ближайшей задачи к выполнению" size="29" type="timestamp" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="is_deleted" nullable="true" remarks="Удалена ли сделка" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="score" nullable="true" remarks="Скоринг сделки" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="labor_cost" nullable="true" remarks="Тип поля &quot;стоимость труда&quot; показывает сколько времени было затрачено на работу со сделкой. Время исчисления в секундах" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="is_price_modified_by_robot" nullable="true" remarks="Изменен ли в последний раз бюджет сделки роботом" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="18" name="is_price_computed" nullable="true" remarks="Был ли бюджет вычеслен по формуле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="19" name="custom_field_id" nullable="true" remarks="id кастомного поля" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="20" name="custom_field_name" nullable="true" remarks="название кастомного поля" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="21" name="custom_field_value_text" nullable="true" remarks="значение кастомного поля типа текст" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="22" name="custom_field_is_deleted" nullable="true" remarks="удалено ли кастомное поле" size="1" type="bool" typeCode="-7"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="23" name="custom_field_code" nullable="true" remarks="Код кастомного поля" size="2147483647" type="text" typeCode="12"/>
      </table>
   </tables>
</database>
