2011-09-12 4 views
0

무엇을하려고하는 것이 User 테이블과 Confirmation 테이블 사이의 약한 관계입니까? User의 약점이 있습니다. 그것을 표현하기 위해, 내 스키마는 다음과 같다 :doctrine과 symfony를 사용하여 약한 관계를 만드십시오.

SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'id' doesn't exist in table. Failing Query: "CREATE TABLE Confirmation (user_id BIGINT, hash VARCHAR(64) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX id_idx (id), PRIMARY KEY(user_id)) ENGINE = INNODB". Failing Query: CREATE TABLE Confirmation (user_id BIGINT, hash VARCHAR(64) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX id_idx (id), PRIMARY KEY(user_id)) ENGINE = INNODB 

그래서,이 교리가 필드 위에 인덱스를 생성하는 것 같다

User: 
    actAs: [Timestampable] 
    connection: doctrine 
    tableName: User 
    columns: 
    id: 
     type: integer 
     primary: true 
     autoincrement: true 
    username: 
     type: string(50) 
     notnull: true 
    name: 
     type: string(50) 
     notnull: true 
     . 
     . 
     . 
    indexes: 
    myindex1: 
     fields: 
     username: 
      sorting: ASC 
      length: 50 
     type: unique 
    relations: 
    Confirmation: 
     foreignType: one 
    attributes: 
    export: all 
    validate: true 

Confirmation: 
    actAs: [Timestampable] 
    connection: doctrine 
    tableName: Confirmation 
    columns: 
    user_id: 
     type: integer 
     primary: true 
    hash: 
     type: string(64) 
     notnull: true 
    relations: 
    User: 
     local: user_id 
     foreign: id 
     type: one 
     foreignType: one 

명령 $ php symfony doctrine:build --all --no-confirmation을 실행할 때, 나는 출력이 오류가 발생했습니다 그 내용은 INDEX id_idx (id)에서 볼 수 있듯이 정의되지 않았습니다 ( id). 왜 교리는이 색인을 생성합니까? 내가 원하는 것을 어떻게 모델링 할 수 있을까?

교리 문서는 관계 문제에 매우 광범위한 아니라, 좋은 문서 사이트에 대한 링크는 매우 도움이 사전에 ... 너무

감사 감사하겠습니다!

답변

0

필자가 아는 한, Doctrine은 기본적으로 (모든) 테이블에 "id"열을 자동으로 추가합니다.

이 문제는 여러 번 설명되어 있습니다, 당신은이 열을 구성 할 수 있습니다

그러나, 난, 미안 '야를 이 기능을 사용 중지하는 방법이 있으면 알 수 없습니다.

관련 문제