<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
  <entity name="Rapsys\AirBundle\Entity\Location" repository-class="Rapsys\AirBundle\Repository\LocationRepository" table="locations">
    <id name="id" type="integer" column="id">
		<generator strategy="AUTO" />
		<options>
		  <option name="unsigned">true</option>
		</options>
    </id>
    <field name="title" type="string" length="32" />
    <field name="description" type="text" nullable="true" />
    <field name="address" type="string" length="32" />
    <field name="zipcode" type="string" length="5" nullable="true" />
    <field name="city" type="string" length="64" />
	<field name="latitude" type="decimal" precision="8" scale="6" />
	<field name="longitude" type="decimal" precision="9" scale="6" />
    <field name="indoor" type="boolean" />
    <field name="hotspot" type="boolean" />
	<field name="created" type="datetime" />
	<field name="updated" type="datetime" />
    <one-to-many field="sessions" target-entity="Rapsys\AirBundle\Entity\Session" mapped-by="location" fetch="LAZY" />
    <one-to-many field="snippets" target-entity="Rapsys\AirBundle\Entity\Snippet" mapped-by="location" fetch="LAZY" />
	<many-to-many field="users" target-entity="Rapsys\AirBundle\Entity\User" mapped-by="locations" fetch="LAZY" />
	<indexes>
      <index name="zipcode" columns="zipcode" />
	  <index name="city_zipcode2" columns="city,zipcode">
        <options>
          <!--#XXX: see https://github.com/doctrine/dbal/pull/2412 and https://stackoverflow.com/questions/32539973/configuring-index-text-length-mysql-in-doctrine-->
          <option name="lengths">NULL,2</option>
	    </options>
	  </index>
    </indexes>
	<lifecycle-callbacks>
      <lifecycle-callback type="preUpdate" method="preUpdate" />
    </lifecycle-callbacks>
  </entity>
</doctrine-mapping>
