Run a method after bench migrate


Looking for a way to persist ‘Report(just the report)’ permission across bench migrates for a role for a given doctype.


I have custom script report based on a doctype and the concerned user role is allowed to see only that data which script report displays.

To restrict the user from seeing data inside doc directly, we’ve set only report permissions for that role using role permission manager. If we don’t provide “report” rights, the user gets permissions error.

The issue is, whenever we run bench migrate after deploying any changes, this permission gets removed automatically.

We tried to setup permissions by adding the role inside doctype itself, but system doesn’t allow it citing that at least one basic permission must be assigned.

Is there a better way to manage this? Alternatively, can I write a script in some hook which will always run after bench migrate?

If my requirement makes a perfect use case to allow addition of role permission with just ‘Report’ permissions to doctype, then I can send a PR for the same.


1 Like

There is a after_migrate hook in frappe that I just found :wink:

I was looking for a solution for v10, but its old school now.

Will accept @neilLasrado’s answer as its relevant v11 onwards.