Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a unique constraints in YML in Doctrine2?

I Want to create a unique constraints on two attributs. The YML configuration with Doctrine2 isn't well documented. So I try to traduct the XML in YML. What's wrong with this code?

unique-constraints:
    name: event_user
    columns:
        event_id: ~
        user_id: ~

Thanks in advance.

like image 398
gperriard Avatar asked Sep 08 '11 11:09

gperriard


2 Answers

Finally I managed to create it by this code:

    uniqueConstraints:
        event_user_idx:
            columns: event_id,user_id

But Thank Reuven for your answer.

like image 131
gperriard Avatar answered Oct 06 '22 11:10

gperriard


You should try that:

uniqueConstraints:
  event_user:
    columns:
      - event_id
      - user_id
like image 34
Reuven Avatar answered Oct 06 '22 13:10

Reuven