symfony doctrine build-sql error

Posted by user313571 on Stack Overflow See other posts from Stack Overflow or by user313571
Published on 2010-04-10T17:52:51Z Indexed on 2010/04/10 18:33 UTC
Read the original article Hit count: 303

Filed under:
|
|
|

I have some big problems with symfony and doctrine at the beginning of a new project. I have created database diagram with mysql workbench, inserted the sql into phpmyadmin and then I've tried symfony doctrine:build-schema to generate the YAML schema. It generates a wrong schema (relations don't have on delete/on update) and after this I've tried symfony doctrine:build --sql and symfony doctrine:insert-sql

The insert-sql statement generates error (can't create table ... failing query alter table add constraint ....), so I've decided to take a look over the generated sql and I've found out some differences between the sql generated from mysql workbench (which works perfect, including relations) and the sql generated by doctrine.

I'll be short from now: I have to tables, EVENT and FORM and a 1 to n relation (each event may have multiple forms) so the correct constraint (generated with workbench) is

ALTER TABLE `form` ADD CONSTRAINT `fk_form_event1` FOREIGN KEY (`event_id`) REFERENCES `event` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

doctrine generated statement is:

ALTER TABLE event ADD CONSTRAINT event_id_form_event_id FOREIGN KEY (id) REFERENCES form(event_id);

It's totally reversed and I am sure here is the error. What should I do? It's also correct like this?

© Stack Overflow or respective owner

Related posts about symfony

Related posts about doctrine