2017-04-05 14 views
1

私はSymfony 3.2.6/PHP 7.1で動作するmanyToMay双方向マッピングを取得しようとしています。私は、エラーDoctrine manyToMany定義が動作しません未定義インデックス:joinTable

せずに実行する

php bin/console doctrine:schema:update --dump-sql 

コマンドを取得することができません[symfonyの\コンポーネント\デバッグ\例外の\ ContextErrorException] お知らせ:未定義のインデックス:joinTable

定義

Busybee\StudentBundle\Entity\Student: 
    type: entity 
    table: student 
    repositoryClass: Busybee\StudentBundle\Repository\StudentRepository 
    id: 
     id: 
      type: integer 
      id: true 
      generator: 
       strategy: AUTO 
    fields: 
     startAtSchool: 
      type: date 
    manyToMany: 
     enrolments: 
      targetEntity: Busybee\StudentBundle\Entity\Enrolment 
      mappedBy: students 

and

Busybee\StudentBundle\Entity\Enrolment: 
    type: entity 
    table: enrolment 
    repositoryClass: Busybee\StudentBundle\Repository\EnrolmentRepository 
    id: 
     id: 
      type: integer 
      id: true 
      generator: 
       strategy: AUTO 
    fields: 
     status: 
      type: string 
      length: '32' 
     lastModified: 
      type: datetime 
     createdOn: 
      type: datetime 
    manyToMany: 
     students: 
      targetEntity: Busybee\StudentBundle\Entity\Student 
      inversedBy: enrolments 

Student EntityのmappedByを削除すると、SQLはdoctrine:schema:updateコマンドを使用して生成されます。 http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#owning-and-inverse-side-on-a-manytomany-associationの例では、inversedByエンティティのjoinTableインデックスが表示されています。このテーブルまたはmappedByエンティティにjoinTableを追加すると、未定義インデックス:joinTable

何か問題がありますか?これはバグですか?どんな助けでも大歓迎です。

クレイグ

+0

データベースを削除/再作成しましたか?既存のデータベースを持っていて、これらのエンティティの構造を追加/変更した場合は、変更時にバグが発生した可能性があります。これは、最初からやり直すことで修正することができます。明らかに、あなたは生産現場でこれをしたくないでしょう! – ehymel

+0

コメントありがとうございます。はい、すべてのテーブルを削除してもエラーは残ります。 –

答えて

0

ここで問題が見つかりました。 Doctrineの問題ではなく、テーブルプレフィックスを追加するために書いた加入者です。定義がmanyToManyアソシエーションであり、所有していない側を無視するために、テーブルプレフィックスサブスクライバのコードを正しく更新するように更新しました。 Doctrineサイトのテーブルプレフィックスコードを使用しています。http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/sql-table-prefixes.html

Craig

関連する問題