1
votes

An example:
I have a User model with a field 'username'
In the $validate array, I have set 'isunique' rule for 'username'. It works, no problem.

But every time I generate fixture, the auto generated value for this field is not unique.

Same problem for other models.

Any idea how to get bake to produce unique values for fileds with 'isunique' rule?

Thank you.

1

1 Answers

0
votes

Why do you even think cake/fixtures would so such a thing? It doesnt!

Your validation rules have absolutely nothing to do with your indexes. Validation get triggered when using validates() or save(). But your database does not have to have those "unique" indexes for it to work.

If you really want them in your fixtures, too, you need to define them there manually (see the primary key index on how to do that).