'unique' validation error

Hi.

I created a new field through the json file and set the unique option as ‘1’. I later realized it shouldn’t actually be a unique field and so I returned the value to ‘0’ but the field keeps throwing a ‘uniquevalidationerror’ anytime I try to create another document with the same value in that field

I’ve tried deleting the field completely and adding it back but it’s still the same! When I check from the UI (customize form), the ‘unique’ option is not checked yet the field still throws the validation error as though it is checked. It’s as though the ‘unique’ option is stuck in the db somewhere

Any ideas how this can be resolved please?

Kind regards,

1 Like

Change the modified value in the json to a later date and do a bench migrate; it reads the json files and updates the db accordingly.

It is better to create new fields via the UI, which accounts for all the changes.

Hi @pratu16x7

Thanks for your response. I added through json file because it’s part of a pull request; when I tried adding from UI, it didn’t show up in the json file

I’ve tried running bench migrate after removing the field from the json file but when I added it again, the same issue came back!

Any ideas?

Thanks

I’d really appreciate any pointers on how this issue can be resolved…

Many thanks

Did you try this? Directly changing the json entails that the modification datetime has to be set manually.

Hi @pratu16x7

Trust you’re doing great. Yes I did that or else the field wouldn’t have been re-created at all. I tried creating a unique field from the UI and then unchecking the ‘unique’ option afterwards (after creating at least one record with that field populated). The same issue occurs and it persists even if you delete all existing records containing that field

It looks like this is actually a bug. Could you pls confirm?

Kind regards,

If table A has fields f1,f2,f3 and table B has fields f1,f2, and I copy json file (text) from table A to table B json file, then I run bench migrate. Will it change table B as same as table A?