开发者

Symfony 1.4/doctrine/sfGuard schema.yml Using sfDoctringGuardPlugin's sfGuardGroup table in a many to many relation

am using the sfGuardPlugin and especially the sfGuardGroup table that am using in a many-to-many relation with a "monitor" table (the many to many table is called ALERT): here is my schema.yml:

Monitor:
  tableName: monitor
  actAs:
    Timestampable: ~
  columns:
    id : {type: integer(4), primary: true, autoincrement: true}
    label: {type: string(45)}
    url: {开发者_如何转开发type: string(80)}
    frequency: {type: integer}
    timeout: {type: integer}
    method: {type: enum, values: [GET, POST]}
    parameters: {type: string(255)}
    Groups:
      class: Groups
      local: monitor_id
      foreign: groups_id
      refClass: Alert

Groups:
  inheritance:
    extends: sfGuardGroup
    type: simple
  relations:
    Monitor:
      class: Groups
      local: id
      foreign: monitor_id
      refClass: Alert

Alert:
  actAs:
    Timestampable: ~
  columns:
    monitor_id: { type: integer(4), primary: true }
    groups_id: { type: integer, primary: true }
  relations:
    Monitor:
      foreignAlias: GroupMonitors
    sfGuardGroup:
      foreignAlias: GroupMonitors

when building all the thigs i get this error :

  SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'sf_guard_g
roup_id' doesn't exist in table. Failing Query: "CREATE TABLE alert (monitor_id
INT, groups_id BIGINT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NUL
L, INDEX sf_guard_group_id_idx (sf_guard_group_id), INDEX id_idx (id), PRIMARY K
EY(monitor_id, groups_id)) ENGINE = INNODB". Failing Query: CREATE TABLE alert (
monitor_id INT, groups_id BIGINT, created_at DATETIME NOT NULL, updated_at DATET
IME NOT NULL, INDEX sf_guard_group_id_idx (sf_guard_group_id), INDEX id_idx (id)
, PRIMARY KEY(monitor_id, groups_id)) ENGINE = INNODB

Any ideas out there?


In the Alert model group_id should be sf_guard_group_id or alternatively you could expand the relations section of sfGuardGroup with the local_id: group_id

Doctrine tries to guess the id's used in the Many-to-many table (if you don't specify them).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜