Symfony doctrine:build –all, erreur SQLSTATE[23000]

Benjamin Longearet 24 février 2010 0
Symfony doctrine:build –all, erreur SQLSTATE[23000]

Problème

Alors vous avez un schema.yml du type :

Profile:
columns:
sf_guard_user_id: integer(4)
email: varchar(255)
relations:
SfGuardUser:
class: sfGuardUser
foreignType: one

Et la vous effectuer la commande suivante :

doctrine-build --all --no-confirmation --and-load

Et bim!

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`xxx`.`profile`, CONSTRAINT `xxx` FOREIGN KEY (`profile_id`) REFERENCES `profile` (`id`))

Solution

C’est tous simplement car vous avez spécifié une taille à sf_guard_user_id: integer(4).

Pour corriger le problème, ne pas spécifié de taille à integer, il prendra sa taille automatiquement.

Bon dév’ :D

Geekos.fr vous recommande les articles suivants

Laissez un message »