Search code examples
phpmysqlsymfony1sfdoctrineguard

Symfony sfDoctrineGuard insert-sql error 1005


I've fresh isntall of Symfony 1.4 with Doctrine ORM.

I'm looking to install the plugin sfDoctrineGuard. I followed the instructions here: http://www.symfony-project.org/plugins/sfDoctrineGuardPlugin

all works fine until this step: symfony doctrine:insert-sql

when I get an error:

SQLSTATE[HY000]: General error: 1005 Can't create table 'kickboxing.#sql-2b5b_a8f' (error 150) Failing Query "ALTER TABLE profile ADD CONSTRAINT profile_sf_guard_user_id_sf_guard_user_id FOREIGN KEY (sf_guard_user_id) REFERENCES sf_guard_user(id)

It did seem to create some tables:

profile sf_guard_forgot_password sf_guard_group sf_guard_group_permission sf_guard_permission sf_guard_remember_key sf_guard_user sf_guard_user_group sf_guard_user_permission

any ideas?

UPDATE: I'm after spotting this really has nothign to do with doctrine/symfony. The issue seems to be with mysql I ran the alter command above in MySQL and of course I get same error.

For reference on that I've Debian Squeeze installed and mysql 5.

UPDATE2 : when i run

SHOW INNODB STATUS;

I get


LATEST FOREIGN KEY ERROR

110927 7:58:35 Error in foreign key constraint of table _kickboxing/#sql-2b5b_a86: FOREIGN KEY (sf_guard_user_id) REFERENCES sf_guard_user(id): Cannot find an index in the referenced table where the referenced columns appear as the first columns, or column types in the table and the referenced table do not match for constraint. Note that the internal storage type of ENUM and SET changed in tables created with >= InnoDB-4.1.12, and such columns in old tables cannot be referenced by such columns in new tables. See http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html for correct foreign key definition.


Solution

  • Looks like a mySql issue. You can get a full (better) description of the error by logging into the mysql console and running

    show innodb status
    

    then look for the LATEST FOREIGN KEY ERROR to get an idea of what went wrong