Duplicate Custom DocPerm

Hello,
I have some custom DocPerms in the fixtures of my app. The problem I encounter is, that every time bench migrate gets executed it adds another entry of the same Custom DocPerms to my database.

What am I doing wrong?

Thank you

1 Like

Please let me know, what more information I can give so that you can help me.

Also had the same problem, did you solved this?

could you add screen to that to could help you

I have the same problem.

in hooks.py I have:

fixtures = [{
    "doctype": "Role",
    "filters": {
            "name": ["in", "tester,engineer"]
            },
    "doctype": "Custom DocPerm",
    "filters": {
        "role": ["in", "tester,engineer"]
    }
}]

this is how role.json looks like:

[
 {
  "_assign": null,
  "_comments": null,
  "_liked_by": null,
  "_user_tags": null,
  "desk_access": 1,
  "disabled": 0,
  "docstatus": 0,
  "doctype": "Role",
  "home_page": null,
  "modified": "2021-02-08 12:06:53.258110",
  "name": "Tester",
  "parent": null,
  "parentfield": null,
  "parenttype": null,
  "restrict_to_domain": null,
  "role_name": "Tester",
  "two_factor_auth": 0
 },
 {
  "_assign": null,
  "_comments": null,
  "_liked_by": null,
  "_user_tags": null,
  "desk_access": 1,
  "disabled": 0,
  "docstatus": 0,
  "doctype": "Role",
  "home_page": null,
  "modified": "2021-02-08 13:31:28.169368",
  "name": "Engineer",
  "parent": null,
  "parentfield": null,
  "parenttype": null,
  "restrict_to_domain": null,
  "role_name": "Engineer",
  "two_factor_auth": 0
 }
]

and custom_docperm.json - only pasting one entry but they are all the same

[
 {
  "amend": 0,
  "cancel": 0,
  "create": 1,
  "delete": 1,
  "docstatus": 0,
  "doctype": "Custom DocPerm",
  "email": 1,
  "export": 1,
  "if_owner": 0,
  "import": 1,
  "modified": "2021-02-08 12:22:41.671825",
  "name": "d572cd524a",
  "parent": "Loopcheck",
  "parentfield": "permissions",
  "parenttype": "DocType",
  "permlevel": 0,
  "print": 1,
  "read": 1,
  "report": 1,
  "role": "Tester",
  "set_user_permissions": 1,
  "share": 1,
  "submit": 0,
  "write": 1
 },

Every time I execute bench update, fixtures get imported

I figured the problem:
Fixture name is generated as a hash and that hash is just random.
When importing fixtures, they just ignore the "name" field and generate a new name.
That means that all fixtures of doctypes that use a hash as name will duplicate on every run of bench migrate. This is really bad!!

Solution is the following:
Just use the after_install in hooks.py to add static data to you app. Use patches.txt to migrate them. I find Fixtures only useful to dump data to the json format

@stephenBDT
Can you please elaborate the solution?