我在Symfony3中有以下XML文件,我想在列videoPublisherDate
中添加一个MYSQL索引,因为我将查询它并根据它进行排序。我可以通过PHPMYADMIN手动添加它,但我想知道如何更新下面的xml,以便它可以自动完成。
由于
<?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 http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="AppBundle\Entity\Videos" table="videos">
<unique-constraints>
<unique-constraint columns="video_id" name="search_idx_videos" />
</unique-constraints>
<id name="id" type="integer" column="id">
<generator strategy="IDENTITY"/>
</id>
<field name="videoSource" type="text" column="video_source" length="65535" nullable="false">
<options>
<option name="fixed"/>
</options>
</field>
<field name="videoId" type="string" column="video_id" length="50" nullable="false">
<options>
<option name="fixed"/>
</options>
</field>
<field name="videoTitle" type="text" column="video_title" length="65535" nullable="false">
<options>
<option name="fixed"/>
</options>
</field>
<field name="videoImage" type="text" column="video_image" length="65535" nullable="false">
<options>
<option name="fixed"/>
</options>
</field>
<field name="videoPublisher" type="text" column="video_publisher" length="65535" nullable="false">
<options>
<option name="fixed"/>
</options>
</field>
<field name="videoPublisherId" type="text" column="video_publisher_id" length="65535" nullable="false">
<options>
<option name="fixed"/>
</options>
</field>
<field name="videoPublisherDate" type="text" column="video_publisher_date" length="65535" nullable="false">
<options>
<option name="fixed"/>
</options>
</field>
<field name="videoLength" type="integer" column="video_length" nullable="false">
<options>
<option name="unsigned"/>
</options>
</field>
<field name="videoActive" type="integer" column="video_active" nullable="false">
<options>
<option name="unsigned"/>
<option name="default">1</option>
</options>
</field>
<field name="videoTags" type="text" column="video_tags" length="65535" nullable="false">
<options>
<option name="fixed"/>
</options>
</field>
</entity>
</doctrine-mapping>
答案 0 :(得分:1)
您可以在xml定义中添加索引,就像使用唯一约束一样:
<indexes>
<index name="name_videoPublisherDate" columns="video_publisher_date"/>
</indexes>