Skip to main content

Change the owner of a repository in the administration database

Symptom

Deleting a login in User Management fails with a foreign-key error:

Requested URL: /Admin/rest/UserManagement/Users/Delete/3
---- Stack Trace --------------
org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback;
SQL [DELETE FROM [AdmUsers] WHERE [UserId]=?]; The DELETE statement conflicted with
the REFERENCE constraint "AdmRepoOwner". The conflict occurred in database "igxAdmin",
table "dbo.AdmRepositories", column 'Owner'.

Cause

The user you're deleting is recorded as the owner of a repository registered in the administration database, so the database won't let the user row be deleted.

Resolution

Reassign the affected repository to another owner in the administration database, then delete the user.

  1. In Microsoft SQL Server Management Studio, open the administration database.

  2. Right-click and select New Query.

  3. Run this query to list the repositories and their owners:

    SELECT TOP 1000 [RepositoryId]
    , [RepositoryName]
    , [RepositoryShortname]
    , [Owner]
    , [UserName]
    FROM [AdmRepositories] JOIN [AdmUsers] ON [Owner] = [UserId]
  4. Find the owner IDs in the results. To find a specific user's owner ID, open User Management → Users in the platform, select the user, and read the ID at the end of the browser address bar — for example …/Admin/UserManagement/Users/Edit/2023, where 2023 is the owner ID.

  5. With the owner ID of the user who should take ownership, run:

    UPDATE [AdmRepositories] SET [Owner] = ? WHERE [Owner] = ?

    Replace the question marks with the new and old owner IDs. You can then delete the original user.