dennisg dennisg - 1 year ago 151
MySQL Question

Doctrine 2 with multiple indexes

I am developing using zend framework and doctrine2.1.

I have generated entities from database.

But the problem is: Doctrine doesn't recognize my indexes. They are not marked in entity annotations at all.

And when I go to validate-schema and dump sql from

orm:schema-tool:update --dump-sql
it generates sql to drop all my indexes across whole database.

I found that Doctrine has following annotation used for defining indexes:


But this allows me to define one index for multiple columns and I don't really need that.

What I want is the ability to define multiple indexes on multiple columns, one index per column.

Is there a way I can achieve this? Is there a way that I can have annotation that defines multiple indexes.

Answer Source

I would say you can insert multiple indexes in the indexes property (but didn't had the time to test it):

@ORM\Index(name="index_name", columns={"database_column1","database_column2"}),
@ORM\Index(name="index_name2", columns={"database_column1"}),
@ORM\Index(name="index_name3", columns={"database_column2"})

Hope this helps you

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download