ProLoser / aggrofolio

The first dedicated Blog-folio platform
unfol.io
1 stars 0 forks source link

Add 'unique' validation rule to all uuid fields #30

Open ProLoser opened 12 years ago

ProLoser commented 12 years ago

So all the tables that import data (company, school, skill, album, media, project) have a column called 'uuid'. This is the unique ID from the REMOTE provider, not local. Right now there is a built-in (to cakephp) rule to check to see if that column is unique.

You can read about CakePHP validation here: http://book.cakephp.org/2.0/en/models/data-validation.html

Anyway, unfortunately this is not enough alone. Although it is extremely unlikely, there is a chance that 2 separate providers might share a uuid. For this reason we should compare unique with uuid and account_id columns combined. This looks like it will require a custom validation function (in all likeliness), which is also documented in the link above.

Please change all models to use a uniqueId validation rule that can compare multiple columns. The rule, if you end up making it from scratch, should go into appModel, however you would simply reference it in the validation attribute declarations in each child model where necessary. If you check the models corresponding to the list at the beginning finding mentions of 'uuid' in the validation should be easy.