<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="TheliaMain"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="../../../../vendor/thelia/propel/resources/xsd/database.xsd" >

  <table name="library_image" namespace="TheliaLibrary\Model">
    <column name="id" primaryKey="true" required="true" type="INTEGER" autoIncrement="true"/>
    <column name="title" type="VARCHAR" />
    <column name="file_name" type="VARCHAR" />
    <behavior name="i18n">
      <parameter name="i18n_columns" value="title, file_name" />
    </behavior>
  </table>

  <table name="library_item_image" namespace="TheliaLibrary\Model">
    <column name="id" primaryKey="true" required="true" type="INTEGER" autoIncrement="true"/>
    <column name="image_id" type="INTEGER" />
    <column name="item_type" type="VARCHAR" />
    <column name="item_id" type="INTEGER" />
    <column name="code" type="VARCHAR"/>
    <column name="visible" type="TINYINT" />
    <column name="position" type="INTEGER" />
    <foreign-key foreignTable="library_image" name="fk_library_item_image_image_id" onDelete="CASCADE" onUpdate="RESTRICT">
      <reference foreign="id" local="image_id" />
    </foreign-key>

    <index name="library_item_image_item_index">
      <index-column name="item_type" />
      <index-column name="item_id" />
    </index>
  </table>

  <table name="library_tag" namespace="TheliaLibrary\Model">
    <column name="id" primaryKey="true" required="true" type="INTEGER" autoIncrement="true"/>
    <column name="title" type="VARCHAR" />
    <column name="color_code" type="VARCHAR" />
    <behavior name="i18n">
      <parameter name="i18n_columns" value="title" />
    </behavior>
  </table>

  <table name="library_image_tag" namespace="TheliaLibrary\Model">
    <column name="id" primaryKey="true" required="true" type="INTEGER" autoIncrement="true"/>
    <column name="image_id" type="INTEGER" />
    <column name="tag_id" type="INTEGER" />

    <foreign-key foreignTable="library_image" name="fk_library_image_tag_image_id" onDelete="CASCADE" onUpdate="RESTRICT">
      <reference foreign="id" local="image_id" />
    </foreign-key>

    <foreign-key foreignTable="library_tag" name="fk_library_image_tag_tag_id" onDelete="CASCADE" onUpdate="RESTRICT">
      <reference foreign="id" local="tag_id" />
    </foreign-key>

  </table>

</database>
