Przy próbie generowania wyświetla mnie się błąd:
tomasz@tomasz-laptop:~/project/symfony$ ./symfony doctrine:build --sql
>> doctrine generating model classes
>> file+ /tmp/doctrine_schema_92534.yml
Invalid schema element named "articles_category" at path "doctrine"
Mój schema to:
# config/doctrine/schema.yml
doctrine:
articles_category:
actAs: { Timestampable: ~ }
columns:
id: ~
name: { type: VARCHAR (255) , index: required , index: required }
description: { type: varchar(255) }
parent: { type: integer }
visible: { type: boolean }
creation_date: { type: timestamp }
moderator: { type: integer }
group: { type: integer , index: required }
articles_entries:
actAs: { Timestampable: ~ }
columns:
id: ~
description: { type: string(255) , index: required , index: unique }
content: { type: string (65535) }
category: { type: integer }
visible: { type: boolean }
creation_date: { type: timestamp }
author: { type: integer }
users:
actAs: { Timestampable: ~ }
columns:
id: ~
login: { type: varchar (32) }
password: { type: varchar (32) }
name: { type: varchar (255) }
last_name: { type: varchar (255) }
creation_date { type: timestamp }
blocked: { type: boolean }
Co jest nie tak z tym category
Prawie poprawna forma:
ArticlesCategory:
actAs: { Timestampable: ~ }
columns:
id: ~
name: { type: string(255) , notnull: true }
description: { type: string(255) }
parent: { type: integer }
visible: { type: boolean }
creation_date: { type: timestamp }
moderator: { type: integer }
group: { type: integer , notnull: true }
ArticlesEntries:
actAs: { Timestampable: ~ }
columns:
id: ~
description: { type: string(255) , notnull: true, unique: true }
content: { type: text }
category: { type: integer }
visible: { type: boolean }
creation_date: { type: timestamp }
author: { type: integer }
Users:
actAs: { Timestampable: ~ }
columns:
id: ~
login: { type: string(32) }
password: { type: string(32) }
name: { type: string(255) }
last_name: { type: string(255) }
creation_date { type: timestamp }
blocked: { type: boolean }
1. (to nie jest błąd, ale...) pamiętaj o tzw. Camel Case (jak kalsę nazwiesz ArticlesEntries to Doctrine stworzy dla niej tabelę articles_entries etc.)
2. Nie index: unique, tylko unique: true
3. Nie index:required, tylko notnull: true
4. Pamiętaj że Doctrine przy generowaniu zapytań dla MySQL nie escapuje nazw kolumn. Ty używasz kolumny "group" w tabeli articles_categories, a "group" jest zarezerwowanym słowem kluczowym SQL - w wyniku tego zapytanie ci się nie wykona, ponieważ MySQL zgłosi błąd składni. Rozwiązanie: albo zmień nazwę kolumny albo zmodyfikuj kod Doctrine tak, aby zaczął nazwy kolumn escapować (gdzieś to kiedyś robiłem, więc jakby co mogę ci podesłać snippeta :))
5. Top level ścieżki to nazwy kolumn/klas a nie "doctrine"