Error when deleting User

We have run into an issue with 5.2.x whereby we can’t delete a User due to the following error:

Reference error
The record(s) are referenced by other records, please remove all the references first.

ERROR: update or delete on table “auth_user” violates foreign key constraint “fk_cd7rbh06u655vqmeaguaihof4” on table “meta_view_custom”
Detail: Key (id)=(5) is still referenced from table “meta_view_custom”.

We are getting the same error on multiple installs.

Okay, fixed it. Needed to work my way through the DB to find all places where the error was causing issues. Nice way to spend a couple of hours - not.

Still don’t understand what created the error, but life goes on.


Yes, that is a common message. In fact you are trying to delete a record that is referenced somewhere else in another record. For example, a user is referenced as creator of on invoice.

<!-- In Invoice object definition -->
<many-to-one name="creator" ref="com.axelor.auth.db.User" title="Creator" />

In the context of relational databases, it requires that if a value of one attribute (column) of a relation (table) references a value of another attribute (either in the same or a different relation), then the referenced value must exist.
So here if you tried to remove a user that is referenced as the creator of an invoice, the delete statement will failed. That’s why there is that error message generated by the database.

In your specific case, the user is references in meta_view_custom table which stored all the personalized views when a user drag/drop panels on dashboard.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.