Doctrine (symfony) YAML schema/fixture constraint trouble

acuellarj

New Member
Morning,
I'm having some trouble creating tables/loading fixtures.
(symfony 1.4.6 with the bundled Doctrine 1.2.3(?))

Tables (simplified):\[code\]Horseman: tableName: Horseman actAs: { Timestampable: ~ } columns: id: { type: integer(4), primary: true, autoincrement: true, unsigned: true } name: { type: string(100), notnull: true }Stable: tableName: Stable actAs: { Timestampable: ~ } columns: id: { type: integer(4), primary: true, autoincrement: true, unsigned: true } info: { type: clob } id_owner: { type: integer(4), unsigned: true } relations: Horseman: { local: id_owner, foreign: id }Horses: tableName: Horses actAs: { Timestampable: ~ } columns: id: { type: integer(4), primary: true, autoincrement: true, unsigned: true } name: { type: string(100), notnull: true } id_owner: { type: integer(4), unsigned: true } id_stable: { type: integer(4), unsigned: true } relations: Horseman: { local: id_owner, foreign: id } Stable: { local: id_stable, foreign: id }\[/code\]
"Horseman" doesn't have any dependencies
"Stable" has one "Horseman"
"Horses" has one "Horseman" and one "Stable"
fixtures:\[code\]Horseman: Hector: name: HectorStable: StableA: info: Lorem Ipsum Dolor Sit Amet id_owner: HectorHorses: Ed: name: Ed id_owner: Hector id_stable: StableA\[/code\]When Inserting the fixtures:\[code\]$ php symfony doctrine:build --all --and-load\[/code\]i get a constraint violation:\[code\]SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`issuetracker/Stable`, CONSTRAINT `Stable_id_owner_Horseman_id` FOREIGN KEY (`id_owner`) REFERENCES `Horseman` (`id`))\[/code\]The "Horseman" entry gets inserted without a problem.
Inserting the other two entries by hand is not a problem either:\[code\]INSERT INTO Stable (id,info,id_owner,created_at,updated_at) VALUES (null,"foo",1,NOW(),NOW())INSERT INTO Horses (id,name,id_owner,id_stable,created_at,updated_at) VALUES (null,"foo",1,1,NOW(),NOW())\[/code\]
(Does symfony save the created insert statements somewhere?)

If i get it right, Doctrine should take care of inserting orders by itself(?) Since I'm giving the correct order anyways that shouldn't be the problem..

In the hope that i just didn't see or didn't get a small thing, would one of you nice guys tell me why i get that constraint violation and/or how to fix it, pretty please..

Thanks.
 
Back
Top