fixtures and Integrity constraint violation

Ignore this. See Update2 here.

I recently upgraded to the latest version of MAMP and now my unit tests that load fixtures have stopped working:


    CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: 

        Integrity constraint violation: 

            1062 Duplicate entry '0' for key 'PRIMARY'

I had a similar problem before when using CDbFixtureManager with a model that uses BIGINT as the primary key and found a work around - don’t use CDbFixtureManager to load fixtures for that model.

But now its models that use integer for the primary key.

Any ideas?

is it auto incremented?

Yes its auto incremented.


Hi I’m having the same problem

did you find your way out of it ?

I tried moving around the order of my fixtures but didn’t seem to work

is it possible to respect FK integrity while using fixtures ?

funny enough the solution came just after posting here

the pb was

The table complaining about the fk constraint was using a specific ID,

and I had deleted all ids in my end fixture thinking that’s how it worked.

Keeping the id in my end table clears the constraint

because the parent table finds what it’s looking for

so to make it short ,

[b]if needed (referenced) by other tables, ids can be kept on table fixtures so that references are respected

otherwise linking with FK gets complicated [/b]