开发者

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. Wh开发者_JAVA技巧at's wrong with this code?

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

Thanks in advance.


Finally I managed to create it by this code:

    uniqueConstraints:
        event_user_idx:
            columns: event_id,user_id

But Thank Reuven for your answer.


You should try that:

uniqueConstraints:
  event_user:
    columns:
      - event_id
      - user_id


I don't know if this part of the documentation has been added recently or not, but here is what it says:

# ECommerceProduct.orm.yml
ECommerceProduct:
  type: entity
  fields:
    # definition of some fields
  uniqueConstraints:
    search_idx:
      columns: [ name, email ]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜